Use SCP to copy files between remote and local hosts

So you need to copy a file you have on a remote server locally, or send a local file to a remote server? Fortunatally, it’s pretty easy with scp. Here’s an example to copy a remote server to the local machine.

scp -P 65124 remoteuser@remotehost:/var/lib/path/to/file.txt /var/lib/path/to/

…which will connect to “remotehost” on port 65124 as “remoteuser” and copy the /var/lib/path/to/file.txt on “remotehost” to the local /var/lib/path/to/ directory.

Need to copy a local file to a remote host? Just switch the parameters up!

scp -P 65124 /var/lib/path/to/file.txt remoteuser@remotehost:/var/lib/path/to/
Please remember to subscribe to the newsletter to stay up to date!

You or someone you know looking to buy or sell?
Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I don't link to anything I don't use myself. You would think this should be self evident these days, but apparently not...

Leave a Reply