How to use SFTP Print

  • 48

 

  • Open/Close connection
  1. Open a connection to a remote system by using the sftp command.

  sftp> remote-system

If the connection succeeds, a confirmation message and prompt are displayed.

  1. If prompted, type your password.

~$  Password: ***********

If the sftp interface accepts your password, it displays a confirmation message and the (sftp>) prompt.

You can now use any of the commands that are supplied by the SFTP interface, including help.

  1. Close the sftp connection.

sftp> bye

Example 3-2 Opening an sftp Connection to a Remote System

This sftp session was established to connect to the remote system pluto:

~$ sftp pluto

Connecting to pluto.

Password: password

sftp>

  • Copy Files From a Remote System
  1. Establish an sftp connection.

See How to Open and Close an sftp Connection to a Remote System.

  1. (Optional) Change to a directory on the local system where you want the files copied to.

sftp> lcd target-directory

  1. Change to the source directory.

sftp> cd source-directory

  1. Ensure that you have read permission for the source files.

sftp> ls -l

  1. To copy a file, use the get command.

Metacharacters may be used with the get command.

sftp> get filename

  1. Close the sftp connection.

sftp> bye

Example 3-3 Copying a File From a Remote System (sftp)

In this example, the user opens an sftp connection to the system pluto, and uses the get command to copy a single file from the /tmp directory.

 ~$ sftp pluto

Connecting to pluto...

Password: xxx

sftp> lcd /tmp

sftp> cd /tmp

 

sftp> ls

filea

files

ps_data

sftp> get filea

/tmp/filea                                100%  494     0.5KB/s   00:00

sftp> bye

  • Copy Files to a Remote System
  1. Change to the source directory on the local system.

The directory from which you type the sftp command is the local working directory and thus the source directory for this operation.

  1. Establish an sftp connection.

See How to Open and Close an sftp Connection to a Remote System.

  1. You can change to the target directory.

sftp> cd target-directory

  1. Ensure that you have write permission in the target directory.

sftp> ls -l target-directory

  1. To copy a single file, use the put command.

Metacharacters may be used with the get command.

sftp> put filename

  1. Close the sftp connection.

sftp> bye

Example 3-4 Copying a File to a Remote System (sftp)

In this example, the user opens an sftp connection to the system pluto, and uses the put command to copy a file from their system to the /tmp directory on system pluto.

$ cd /tmp

$ sftp pluto

Password: xxx

sftp> cd /tmp

sftp> put filef

uploading filef to /tmp/filef

filef                                     100%  325     0.3KB/s   00:00

sftp> ls

filea

filef

files

sftp> bye

 

Thank you!

Please do visit us @ https://www.stradsolutions.com/order/index.php?rp=/knowledgebase for more related topics.

 

 

 


Was this answer helpful?

« Back