As a network admin I work with a lot of different server systems and remote computer. One of the questions I was wondering a lot is how to transfer remote files to my Mac. This could be anything from readme files, password files up to my latest case a VPN client certificate. Most of the times these files are created on the remote server but you need them locally. One option would be to use FTP services to access the remote file tree and download the files. But another, maybe more convince way, would be using scp.
There is no much preparation needed. SCP (Secure Copy Protocol or just Secure Copy) is build into every Mac (and Windows or Linux). SCP is not only providing authentication against the remote host but also encryption during transfer and using the standard port 22. Therefore it is one of the industry standards to transfer digital files between two systems and was funded already in 1982. Basically the basis of SCP is also SSH (secure shell) which is the same as for FTP or sFTP.
SCP would be used in the terminal shell. The basic syntax is quite simple:
scp source destination
If you want to copy files downstream you have to authenticate yourself against the remote host. Do this by just adding your username and host as prefix of the source.
scp email@example.com:/configs/file.conf .
In this example we copy a file.conf from the remote folder configs on the host 10.10.0.221 to our current location . with the user root.
Tip: Just navigate Finder to the location where you want to download the file and start a new terminal session from there with mark folder - right-click - New Terminal Session. With this you can always use the dot for the destination
The terminal now prompts for the users password. After you confirmed the password you can observe the download progress:
Open the destination folder from the terminal with
to review your file(s).
You could enhance the scp command with some options depending on your use-case:
-C Enable gzip compression on the transfer -o Lets you specify more ssh options -P Lets you speficy the remote port -p Keeps remote meta data of the files -r recursive copy of the remote folder structure