JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Managing Remote Systems in Oracle Solaris 11.1     Oracle Solaris 11.1 Information Library
search filter icon
search icon

Document Information

Preface

1.  Working With Remote Systems (Overview)

2.  Administering the FTP Server (Tasks)

3.  Accessing Remote Systems (Tasks)

Accessing Remote Systems (Task Map)

Logging In to a Remote System (ssh)

Authentication for Remote Logins (ssh)

The /etc/ssh_known_hosts and .ssh/known_hosts Files

What Happens After You Log In Using Secure Shell

How to Log In to a Remote System (ssh)

Logging Out of a Remote System (exit or logout)

Logging In to a Remote System to Copy a File (sftp)

Essential sftp Commands

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

How to Copy Files From a Remote System (sftp)

How to Copy Files to a Remote System (sftp)

Remote Copying With the scp Command

Security Considerations for Copy Operations

Specifying the Source and Target for Copy Operations

How to Copy a File Between Two Systems (scp)

Index

Logging In to a Remote System to Copy a File (sftp)

The sftp command is an interactive file transfer program with a user interface similar to ftp. However, sftp uses the SSH File Transfer Protocol to create a secure connection to the server. Not all options available with the ftp command are included in the sftp command, but many of them are.

Essential sftp Commands

The following table lists essential sftp commands.

Table 3-2 Essential sftp Commands

Command
Description
sftp remote-system
Establishes an sftp connection to a remote system. For instructions, see How to Open and Close an sftp Connection to a Remote System.
sftp remote-system:file
Copies the named file from remote-system.
bye
Quits the sftp session.
help
Lists all sftp commands.
ls
Lists the contents of the remote working directory.
lls
Lists the contents of the local working directory.
pwd
Displays 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.

For more information, see the sftp(1) man page.

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

  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.

  2. If prompted, type your password.
    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. The principal commands are summarized in Table 3-2.

  3. 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>

How to Copy Files From a Remote System (sftp)

  1. Establish an sftp connection.

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

  2. (Optional) Change to a directory on the local system where you want the files copied to.
    sftp> lcd target-directory
  3. Change to the source directory.
    sftp> cd source-directory
  4. Ensure that you have read permission for the source files.
    sftp> ls -l
  5. To copy a file, use the get command.

    Metacharacters may be used with the get command.

    sftp> get filename 
  6. 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

How to Copy Files to a Remote System (sftp)

  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.

  2. Establish an sftp connection.

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

  3. You can change to the target directory.
    sftp> cd target-directory
  4. Ensure that you have write permission in the target directory.
    sftp> ls -l target-directory
  5. To copy a single file, use the put command.

    Metacharacters may be used with the get command.

    sftp> put filename
  6. 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