User Tools

Site Tools


cs101:sftpfromlinux

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
cs101:sftpfromlinux [2020/09/04 03:00] – [Navigating with SFTP] localadmincs101:sftpfromlinux [2020/09/08 21:59] (current) – [How to Connect with SFTP] localadmin
Line 1: Line 1:
 ====== How to transfer files between Linux/Mac computers using SFTP from the Command Line ====== ====== How to transfer files between Linux/Mac computers using SFTP from the Command Line ======
-This information is provided for the Ubuntu/Debian editions of Linux used in the CS Department. Other Linux versions may vary.+This information is provided for the [[https://www.ubuntu.com/|Ubuntu]]/Debian editions of Linux used in the CS Department. Other Linux versions may vary.
  
  
Line 7: Line 7:
 ===== What Is SFTP? ===== ===== What Is SFTP? =====
  
-In Linux, you can use the Secure File Transfer Protocol (SSH File Transfer Protocol) (SCP) from the command line (CLI) (the sftp command) to securely copy files and directories between remote hosts.+In Linux, you can use the Secure File Transfer Protocol (SSH File Transfer Protocol) (**[[cs101:sftp|SFTP]]**) from the command line (**[[cs101:cli|CLI]]**) (the sftp command) to securely copy files and directories between remote hosts.
  
-In most cases, SFTP is preferable to FTP because of its underlying security features and ability to piggy-back on an SSH connection. FTP is an insecure protocol that should only be used in limited cases or on trusted networks. FTP is NOT available on CS Department computers.+In most cases, SFTP is preferable to **[[cs101:ftp|FTP]]** because of its underlying security features and ability to piggy-back on an SSH connection. FTP is an insecure protocol that should only be used in limited cases or on trusted networks. FTP is NOT available on CS Department computers.
  
  
Line 22: Line 22:
  
   * Name of the account on the host computer (remote_username)   * Name of the account on the host computer (remote_username)
-  * Hostname (i.e. FQDN) of the computer on which the source file resides (remote_host)+  * Hostname (i.e. [[cs101:fqdn|FQDN]]) of the computer on which the source file resides (remote_host)
  
 Options can include things like [-oPort=custom_port] if not connecting to the standard SSH port 22. Options can include things like [-oPort=custom_port] if not connecting to the standard SSH port 22.
Line 31: Line 31:
  
 ==== Navigating with SFTP ==== ==== Navigating with SFTP ====
-Once connected+Once connected to the remote host, you can navigate around the remote file system with commands similar to the Unix/Linux Shell. 
 + 
 +  * pwd: show remote working directory. 
 +  * ls:  view contents of the current remote directory.  
 +  * cd:  change remote directory. 
 +You can direct commands towards the local file system by preceding them with an “l” for local. 
 +  * lpwd: show local working directory. 
 +  * lls:  view contents of the current local directory.  
 +  * lcd:  change local directory. 
 + 
 + 
 + 
 + 
 +==== Transferring Remote Files to the Local System ==== 
 +Transferring files from the remote system is accomplished by using the appropriately named “get” command: 
 + 
 +To download a file from the remote host. 
 +  get remote_filename 
 +   
 +To download a file from the remote host and rename. 
 +  get remote_filename new_local_filename 
 + 
 +To download a directory and it's contents. 
 +  get -r remote_directory 
 + 
 +To preserve full file permissions and access times during the copy, use the -p flag. 
 +  get -p remote_filename 
 + 
 + 
 + 
 + 
 + 
 +==== Transferring Local Files to the Remote System ==== 
 + 
 +Transferring files to the remote system is accomplished by using the appropriately named “put” command: 
 + 
 +To upload a file to the remote host.  
 +  put local_filename 
 + 
 +To upload an entire local directory to the remote host. 
 +  put -r local_directory 
 + 
 + 
 + 
 + 
 +==== Quitting SFTP ==== 
 +To quit a SFTP session use the exit command 
 +  exit 
 +===== Getting Help in SFTP ===== 
 +SFTP has a help command. This gives you access to a summary of the SFTP help. You can call it by typing either of these in the prompt: 
 + 
 +  help 
 + 
 +  ? 
 + 
 +This will display a list of the available commands: 
 + 
 +You can find more information on Ubuntu SFTP in the [[http://manpages.ubuntu.com/manpages/focal/en/man1/sftp.1.html|Ubuntu man pages]]
cs101/sftpfromlinux.1599188420.txt.gz · Last modified: by localadmin