We explain every GNU/Linux command by examples in this blog!

As long as you can access a site with ssh account, then you can transfer files using scp, try to imagine , you are from host A and you have access to host B through ssh with same user account call foobar. You can copy a file from host B by example as bellow

scp foobar@hostB:~/myfile.txt .

:~/ actually leads you to home directory of foobar, as long as the file is accessible by the account foobar in host B, than it can be transfer. The other way round is transfer file from host A to host B.

scp myfile.txt foobar@hostB:~/

It support to copy a folder from one host to another by adding option -r

7 Responses to “transfering files through ssh”

[…] If you want to transfer one or few files which you have know the location, scp would be enough. SCP example will be here. But if do not know the location of the file, and you want to login to browse the directories? consider sftp. Login to sftp is like login to ssh, sftp foobar@192.167.8.9 […]

Consider using rsync. It supports ssh and remote sources, but it uses a lot less bandwidth only transferring what needs to be changed rather than everything like scp.
You need rsync on both servers, however.

I would like to thank you for the efforts you have put in writing this web site. I am hoping the same high-grade blog post from you in the upcoming as well. In fact your creative writing skills has inspired me to get my own website now. Really the blogging is spreading its wings rapidly. Your write up is a great example of it.