How to Connect to an SFTP Server in Ubuntu

To connect to an SFTP server in Ubuntu, you normally only need the server hostname or IP address, your username, and either a password or SSH key. In a Terminal, run sftp username@server. On Ubuntu Desktop, you can also connect through Files using an SSH address such as ssh://username@server.

What you need before connecting

SFTP is the SSH File Transfer Protocol, so it uses an encrypted SSH connection rather than traditional FTP. Ask the server administrator or hosting provider for the hostname, username, authentication method, and port. Port 22 is the usual SSH/SFTP port, but a server can use another one.

Ubuntu includes the OpenSSH client on many installations. If the sftp command is not available, install the client package:

sudo apt update
sudo apt install openssh-client

Ubuntu's OpenSSH documentation identifies openssh-client as the client package and openssh-server as the server package. You do not need to install the server package merely to connect to someone else's SFTP server.

Connect to SFTP from the Ubuntu Terminal

  1. Open Terminal.
  2. Run sftp username@hostname. For example:
    sftp alex@sftp.example.com
  3. On the first connection, SSH may display the server's host-key fingerprint. Verify that fingerprint with the server administrator before accepting it, especially for an internet-facing server.
  4. Enter your password when prompted, or let OpenSSH use your configured SSH key. A successful login displays an sftp> prompt.
Ubuntu Terminal showing an SFTP connection to sftp.example.com and the sftp prompt
An SFTP session opens in the Ubuntu Terminal after SSH host verification and authentication.

If the server uses a non-default port, use uppercase -P:

sftp -P 2222 alex@sftp.example.com

The Ubuntu SFTP manual page documents -P for a custom port and -i for selecting a private-key file.

Browse, download, and upload files

Once connected, these commands cover most everyday transfers:

  • ls — list files on the remote server.
  • pwd — show the current remote directory.
  • lpwd — show your current local directory.
  • cd folder — change the remote directory.
  • lcd folder — change the local directory.
  • get report.pdf — download a remote file to the current local directory.
  • put photo.jpg — upload a local file to the current remote directory.
  • bye — close the SFTP session.
Ubuntu Terminal showing SFTP ls get report.pdf and put photo.jpg commands
The get command downloads from the server, while put uploads from the local Ubuntu computer.

Connect with Ubuntu Files instead of the command line

Ubuntu Desktop's GNOME Files app can browse an SSH server like another file location. GNOME's current help uses the ssh:// URL scheme for this connection.

  1. Open Files and select Other Locations in the sidebar.
  2. In Connect to Server, enter ssh://username@hostname. For a custom port, add it after the host, such as ssh://alex@sftp.example.com:2222.
  3. Click Connect and provide the requested credentials.
  4. Browse the remote folders normally. Drag or copy files between the remote location and local folders to transfer them.
Ubuntu Files Other Locations screen with Connect to Server using an ssh URL
GNOME Files can connect to an SSH/SFTP account from Other Locations using an ssh:// server address.

See the official GNOME Files server-connection guide for the supported URL format and connection flow.

If the remote Ubuntu machine is your server

If you control the remote Ubuntu computer and it is not already running SSH, install OpenSSH Server on that remote machine:

sudo apt update
sudo apt install openssh-server
systemctl status ssh
Ubuntu Terminal installing openssh-server and showing the SSH service as active
Install OpenSSH Server on the remote Ubuntu host only when you are setting up the machine that will accept SFTP connections.

For key-based authentication, Ubuntu recommends Ed25519 keys. On your client, create a key with ssh-keygen -t ed25519, then, for a server you administer, install the public key with ssh-copy-id username@server. Keep the private key private and protect it with a passphrase where appropriate.

Fix common SFTP connection problems

  • Connection refused: confirm the hostname and port, and if you manage the server, check that the SSH service is running and that network/firewall rules allow the SSH port.
  • Permission denied: verify the username and authentication method. With keys, confirm that the correct public key is authorized for that account.
  • Connection timed out: check DNS, routing, VPN requirements, the server's public accessibility, and the port number.
  • Host key changed: do not automatically remove the warning. First verify with the server administrator that the host key was legitimately replaced; an unexpected change can indicate that you are reaching the wrong system or a security problem.

For most Ubuntu users, the Terminal method is the fastest and most transparent option, while GNOME Files is convenient when you prefer drag-and-drop transfers.

Leave a Comment

How to Record Speaker Output on Linux with Audacity

How to Record Speaker Output on Linux with Audacity

Capture Linux desktop audio in Audacity by routing its recording stream to your output device’s monitor source. Follow PulseAudio and PipeWire steps, export tips, and fixes for silent tracks.

How to Use Dropbox on Linux: Install and Sync Your Files

How to Use Dropbox on Linux: Install and Sync Your Files

Install Dropbox on Linux from the official package, sign in, sync a local folder, manage selective sync, and check status from the command line.

How to Install Inkscape on Linux: Ubuntu, Fedora, Arch, and More

How to Install Inkscape on Linux: Ubuntu, Fedora, Arch, and More

Install Inkscape from your Linux distribution’s repositories, the Ubuntu stable PPA, Snap, or Flathub, with current commands and notes for choosing a package source.

How to Find and Remove Duplicate Files on Linux With FSlint

How to Find and Remove Duplicate Files on Linux With FSlint

Use FSlint to scan selected Linux folders, review duplicate groups, and safely delete redundant files or learn when hard-link merging is appropriate.

How to Install SABnzbd on Linux and Configure It

How to Install SABnzbd on Linux and Configure It

Install SABnzbd on Ubuntu or Debian, or run it in Docker on another Linux host. Then open the web interface and configure your provider and download folders.

How to Install the Paper GTK Theme on Linux

How to Install the Paper GTK Theme on Linux

Install the Paper GTK theme from supported Linux repositories, enable it for GTK apps in GNOME Tweaks, and see what the legacy theme can and cannot change.

How to Install and Set Up Plex on OpenMediaVault with Compose

How to Install and Set Up Plex on OpenMediaVault with Compose

The old OpenMediaVault Plex plugin is archived. Set up Plex on OMV 8 with OMV-Extras, the Compose plugin, persistent storage, and Plex’s official container.

How to Clean and Speed Up Ubuntu Safely

How to Clean and Speed Up Ubuntu Safely

Clean and speed up Ubuntu with safe APT cleanup, storage checks, and startup controls that help free space and troubleshoot a sluggish desktop.

How to Install the Hiri Email Client on Linux

How to Install the Hiri Email Client on Linux

Install Hiri on Linux with its Snap package or official tarball, add a desktop launcher, and check supported accounts plus a warning about Hiri’s old Snap release.

How to Get System Specifications for a Linux PC

How to Get System Specifications for a Linux PC

Use Fastfetch and built-in Linux commands to check your distro, kernel, CPU, memory, graphics, storage, and connected devices, then save a clear report.