Downloading a file:
scp username@hostname:pathname/filename .
$ scp firstname.lastname@example.org:/Library/WebServer/Documents/support/FireFTP/PopupMenu.jpg .
Don’t forget the space before the final “.”.
Uploading a file:
The general format for the command to upload to the server is:
scp filename username@hostname:pathname
For example, if I want to transfer the file PopupMenu.jpg in the folder /Users/jtbell/Sites/support/FireFTP/ on my computer, to the directory (folder) Library/WebServer/Documents/support/FireFTP/ on the server, I enter the following:
$ cd /Users/jtbell/Sites/support/FireFTP $ scp PopupMenu.jpg email@example.com:/Library/WebServer/Documents/support/FireFTP/ Password: (enter password here) PopupMenu.jpg 100% 83KB 82.7KB/s 00:00 $
After I enter the command, it asks you for your login password on the server. (Exception: if this is your first time using scp, you may first get a warning about the authenticity of the server. See this page for more information.) If there is already a file named PopupMenu.jpg in that directory, it is replaced.
I could also combine the two commands by giving the complete path to the file on my computer:
$ scp /Users/jtbell/Sites/support/FireFTP/PopupMenu.jpg firstname.lastname@example.org:/Library/WebServer/Documents/support/FireFTP/
but that’s a lot to type all at once! Besides, I often want to transfer more than one file, and it’s a nuisance to type the path over and over again.
You can also use the usual Unix-style wildcard characters in the filename. For example, to upload all the .jpg files in the current folder, I would use:
$ scp *.jpg email@example.com:/Library/WebServer/Documents/support/FireFTP/
For our Windows friends, use WinSCP