does ssh have a facility to exchange files when already connected?
Solution 1:
Recent versions of OpenSSH support connection multiplexing. Look at the ControlMaster
and ControlPath
options for ssh_config.
Using this feature, you'd still have to run scp
or sftp
to perform a file transfer, but the transfer would run through your existing SSH connection.
Solution 2:
You will always need to identify yourself to the machines you are connecting to. You can set it up to work with encrypted keys so no password is needed but the authentication is still there.
The easiest way to transfer files between remote systems is scp
, part of the ssh
package. Lets say your local machine is 1.2.3.4.
and your local user tom
and the remote machine is 5.6.7.8
and your remote user is jon
.
-
To copy a file from the remote server to your local machine when logged in to the server:
scp /home/jon/foo.txt [email protected]:/home/tom/
Of course, you will still have to identify yourself (to your local machine this time). Not, however, to the server.
-
To copy a file from the remote server to your local machine when not logged in to the server:
scp [email protected]:/home/jon/foo.txt /home/tom/
This way, you only need to identify yourself once, you don't need to open a separate
ssh
connection.
You can also copy between remote servers, anywhere you have ssh
access to basically. The general format of the command is
scp user1@machine1:/path/to/source user2@machine2/path/to/destination