Skip to Main Content

unix scp sftp

UNIX CONNECTIVITY/FILE TRANSFER

To transfer files back and forth to CS unix servers from a unix system, use either the scp(non-interactive) or sftp(interactive) commands. Both of these commands will do file transfers between unix/linux 'ssh' hosts, with each one working differently.

Click HERE for instructions on how to open up a terminal session to a CS unix system via ssh.

1. SCP :  This utility provides non-interactive file transfers between ssh-enabled unix/linux systems. After contacting the ssh server/host, the scp program will prompt you for your password. If that password is correct, the file transfer will take place, with a status message indicating file transfer times and other items.

To copy a file TO a CS server from another UNIX server :
  scp  localfilename  cs_user_name@cs.uml.edu:~/destination_file_name

To transfer entire directory structures, use the '-r' option to scp:
  scp  -r  localdirectory  cs_user_name@cs.uml.edu:~/destination_directory_name 

To transfer files/directories FROM the CS server while logged into a remote unix/linux server, reverse the syntax:
  scp [-r] cs_user_name@cs.uml.edu:~/destination_file_name  localfilename

If the username you are using on the local unix/linux system matches the remote unix/linux system username, you do not need to use the username prefix before the name of the ssh server you are transferring files to/from:

  scp [-r] localfilename  cs.uml.edu:~/destination_file_name
  scp [-r] cs.uml.edu:~/destination_file_name  localfilename

2. SFTP :  This utility provides a interactive file transfer session between ssh-enabled unix/linux systems. After contacting the ssh server/host, the scp program will prompt you for your password. If that password is correct, you will be entered into an interactive command line session, analogous to the standard 'FTP' program.

To start the sftp program, type :

  sftp server_name

This will connect to the sftp server and will prompt you for your password. As with scp and ssh, it will use the same username as the user that executed the sftp program. If you wish to 'sftp' to another server with a different username, use the following syntax:

  sftp username@server_name

Once you successfully log into the 'sftp' session, your prompt will be "sftp>". From this prompt you can use the get command to receive files from the server you have connected to and the put command to send files to the server you have connected to.

To learn more about using sftp, type man sftp at your unix prompt.