Smart way to copy multiple files from different paths usinc scp

后端 未结 5 868
北荒
北荒 2021-02-08 13:04

I would like to know an easy way to use scp to copy files and folders that are present in different paths on my file system. The ssh destination server requests a password and I

5条回答
  •  日久生厌
    2021-02-08 13:24

    From this site:

    Open the master

    SSHSOCKET=~/.ssh/myUsername@targetServerName ssh -M -f -N -o ControlPath=$SSHSOCKET myUsername@targetServerName

    Open and close other connections without re-authenticating as you like

    scp -o ControlPath=$SSHSOCKET myUsername@targetServerName:remoteFile.txt ./

    Close the master connection

    ssh -S $SSHSOCKET -O exit myUsername@targetServerName

    It's intuitive, safer than creating a key pair, faster than creating a compressed file and worked for me!

提交回复
热议问题