How to Open and Close an SFTP Connection to a Remote System

March 8, 2023 / General Discussion

If you are unsure of how to open and close an SFTP connection to a remote system, we have you covered. Just check out the steps mentioned below to get all the information you need.

Command Description
sftp remote-system Builds an sftp connection to a remote system. 
sftp remote-system:file Copies the named file from the remote system.
bye Quits the sftp session.
help Lists all sftp commands.
ls Creates lists of the contents of the remote working directory.
lls Creates lists of the contents of the local working directory.
pwd Shows the name of the remote working directory.
cd Changes the remote working directory.
lcd Changes the local working directory.
mkdir Creates a directory on the remote system.
rmdir Deletes a directory on the remote system.
get Copies a file from the remote working directory to the local working directory.
put Copies a file from the local working directory to the remote working directory.
delete Deletes a file from the remote working directory.

How to Open and Close an sftp Connection to a Remote System?

  1. Use this sftp command to open a connection to a remote system.
    $ sftp remote-system

When the connection succeeds, there will be a prompt along with a confirmation message prompted.

  1. Insert your password if asked.
    Password: password

If your password is accepted by the sftp interface, you will have the (sftp>) prompt and a confirmation message displayed. The commands provided by the sftp interface can be used now, including help.

  1. Close the sftp connection.
    sftp> bye

Leave a Reply

Your email address will not be published. Required fields are marked *