Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Linux Commands»How to Download and Upload files with SFTP Command

    How to Download and Upload files with SFTP Command

    RahulBy RahulMarch 2, 20192 Mins ReadUpdated:September 25, 2021

    SFTP (SSH File Transfer Protocol) is a secure protocol to transfer files between systems. It uses an encrypted secure shell (SSH) for the communication between two systems.

    You can also use this or this tutorial to configure sftp only user on your Linux system without SSH access.

    In this tutorial you will learn:

    1. Connect to remote sftp server
    2. Navigation in file system
    3. Upload files to SFTP server
    4. Download files from SFTP server
    5. Close SFTP connection

    Connect to Remote SFTP Server

    Use sftp command-line utility to connect remote sftp system. You need the sftp user and hostname or IP address of the remote host.

    sftp [email protected] 
    

    Enter sftpuser account password to connect:

    [email protected]'s password:
    sftp>
    

    Navigate and View Files

    Navigation in directories on SFTP is as simple as the local system. Use ‘pwd’ command to check the current working directory.

     pwd 
    
    Remote working directory: /
    

    Then use the ‘ls’ command to list all files and directories in the current directory.

     ls 
    

    To navigate to other directories use ‘cd’ command followed by destination directory.

     cd uploads 
    

    Use ‘cd ..’ to navigate to the parent directory.

     cd .. 
    

    Upload files to SFTP

    Now, I need to upload some files under uploads directory. Use the ‘put’ command to upload README.md from the local system to the remote sftp directory.

    put README.md 
    

    You can also provide the absolute path of the local file and remote directory without navigating directories.

    put /var/www/README.md /uploads/20191115/ 
    

    sftp upload command example

    Download Files from SFTP

    To download files from the remote sftp directory use the ‘get’ command. For example to download REMOTE_FILE.md from the remote system to the current local directory.

    get REMOTE_FILE.md
    

    Similarly, you can provide an absolute path to download files.

    get /uploads/REMOTE_FILE.md /var/www/
    

    sftp download command example

    Quit the SFTP Connection

    Simply say bye to your remote SFTP server. This will disconnect the SFTP connection and return to your local shell.

    bye 
    

    Alternatively, you can also use quit or exit commands to close the SFTP session.

    Conclusion

    In this tutorial, you have learned to how to download and upload files using sftp command line.

    command linux SFTP
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow To Install Sendmail on Debian 10 (Buster)
    Next Article How To Install Oracle Java on Debian 10 (Buster)

    Related Posts

    (Resolved) userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms

    Updated:May 10, 20221 Min Read

    How to Search Recently Modified Files in Linux

    2 Mins Read

    Bash Printf Command

    Updated:December 23, 20212 Mins Read

    (Resolved) -bash: /bin/mv: Argument list too long

    Updated:January 13, 20222 Mins Read

    Tee Command in Linux with Examples

    4 Mins Read

    How to Scan Open Ports with Nmap

    5 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Install Sublime Text 4 on Ubuntu 22.04
    • How to Enable / disable Firewall in Windows
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.