How to transfer a file over ssh from one machine to another

file-transferssh

My professor wants us to email him source files, but he wants us to edit over ssh using vi. How do I transfer a file over ssh from one machine to another?

Best Answer

To transfer a file over ssh you should use the scp command.

Basic usage is :

[you@localhost ~]$ scp examplefile yourusername@remoteserver:/home/yourusername/

It will copy over SSH the file examplefile to the remote server at the location /home/yourusername/examplefile

More concrete example :

[Moshe@localhost ~/mywork]$ scp thework.zip Moshe@192.168.1.21:/home/Moshe/

Where it is assumed your local file is /home/Moshe/mywork/thework.zip and you have permission to login to the server 192.168.1.21 and to write in the remote directory /home/Moshe

You will end with the file copied under /home/Moshe/thework.zip on the remote server.

If you are not working under Linux or any Unix-based system locally (ie. you're on Windows typically), a tool like WinSCP will enable you to transfer the file over SSH with help of a graphical interface.

Related Question