Using SFTP on Linux/UNIX

Tags linux Unix

Overview

SFTP (Secure File Transfer Protocol) allows easy transfer of files between a remote and local system. It is built on top of SSH (Secure Shell) and commonly used to transfer files between a server and a local workstation. Some UTD systems that you may use SFTP with include, but are not limited to: Giant/PubSSH, CS Linux Servers, etc.

Connecting to a Remote System

Before connecting to a remote system, you must know the system hostname and your UTD credentials.

  1. Open a Terminal.
  2. Enter sftp NetID@[system hostname]
    • Ex: sftp abc123456@giant.utdallas.edu
  3. When prompted, enter your UTD password.
  4. Once connected, you will be dropped into the sftp> prompt.

Terminal: sftp NetID@giant.utdallas.edu.

Transferring Files

Commonly Used Commands

  • help – lists all available commands
  • CTRL+L – clears the terminal
  • pwd – “print working directory” displays the current path
  • ls – lists files and directories
    • Optional: Specify path, -l for details, -a to include hidden
  • get – copy a remote file to the local system
  • put – copy a local file to the remote system
  • exit or quit – quit SFTP
Note: By default, the get/put commands will copy files to the working directory of the remote system from the directory of the local system where the sftp command was executed (working directory), or from the working directory of the local system to the working directory of the remote system.

Examples

Copy File to Remote System

sftp> put copy-me.txt

The file copy-me.txt is copied from ~/copy-me.txt to the working directory of the remote system.

Copy File to Remote System (With File Path)

sftp> put ./foo/bar/file.txt ./files/

Copy the file from ~/foo/bar/file.txt to ./files/file.txt

Copy Directory to Local System

sftp> get -R foo/

The directory foo will be copied to the local system in the current working directory.

Details

Article ID: 463
Created
Mon 11/22/21 12:57 PM
Modified
Mon 10/2/23 12:35 PM