Secure Copy (scp) – Optional
When transferring files between computers or managing remote servers, the (scp) command can be used to securely copy files and directories over a network. This command lets you send files from your local machine to a remote server or vice versa, ensuring data integrity and confidentiality through SSH (Secure Shell) encryption.
Note: You’ll want to be on your terminal, but in the local (not ssh’d in).
Like cp
, the order in scp
is scp from to.
eos$ scp username@remotehost:path localfile
You can also use it to upload files to the remote.
eos$ scp localfile username@remotehost:path
-r is required for copying directories.
eos$ scp -r username@remotehost:path localdir
scp
You can copy files securely between a local machine and a remote host using the scp command.
Without options, scp copies the specified file to the given remote host and directory, or vice versa. After executing the command, the file will be present in both the source and destination locations.
eos$ scp -r localdir username@remotehost:path
Using the -r option allows you to recursively copy entire directories, preserving the directory structure.
Should I expect an output?
Yes:
scp
file.txt 100% 1234KB 2.3MB/s 00:00
directory/file.txt 100% 1234KB 2.3MB/s 00:00
Example (with a Terminal)
This method may be faster than using FileZilla/Cyberduck if you are having trouble using those programs. Note that FileZilla uses sftp
, which is a secure way to transfer files and other file operations, like creating directories, removing files, and changing file permissions, which scp
does not support.
But for E 115 we mostly need to copy files over. Here’s how it works on eos. Let’s suppose I have a file called file2.txt in my MyE115 directory on the NFS. I would like to copy it to my local (so I can then upload it to Moodle or Gradescope!).
Then you can copy the file into your local Documents like this:
eos$ scp unityid@remote.eos.ncsu.edu:/mnt/ncsudrive/u/unityid/MyE115/file2.txt ~/Documents/.
Note that this won’t work with PuTTY, since you don’t have a “local” terminal in the same sense as on Mac/Linux. You may try PuTTY pscp (instructions here).
Note: These instructions are only provided as an alternative to using FileZilla and are not required for the class!