Talk to the NOC, IST hours — +91 75994 50220 support@bigdomainhost.com
Guide

What SFTP is, and how to use SFTP and SCP over SSH

SFTP and SCP move files to and from a server over an encrypted SSH connection. This guide explains what each one is and gives you the exact commands, client settings and fixes you need.

Short answer: What is SFTP? It is the SSH File Transfer Protocol, a secure way to upload and manage files on a server over SSH, usually on port 22. Connect with sftp user@host and use put and get, or use FileZilla or WinSCP. For a quick one-off copy, run scp file user@host:/path, adding -r for folders and -P for a custom port.

What is SFTP?

SFTP is a way to upload, download and manage files on a server over an encrypted SSH connection. It runs inside the same kind of session you use for a terminal login, normally on port 22, so your password or key, your commands and the file contents are all encrypted. If you can log in to a server with SSH, you can almost always use SFTP with the same username and key.

SCP is an older, simpler tool for one-line copies over SSH, while SFTP gives you an interactive session in which you can list, rename, delete and change permissions. This guide covers both, plus rsync and GUI clients.

Quick checklist

  1. Confirm SSH access and note the host, username and SSH port.
  2. Set up an SSH key rather than relying on a password.
  3. For an interactive session, run sftp user@host and use put and get to move files.
  4. For a one-off copy, run scp file user@host:/path/; add -r for folders and -P for a custom port.
  5. For large or repeated syncs, use rsync over SSH.
  6. After uploading, check ownership and permissions with ls -l.

What does SFTP stand for?

SFTP stands for SSH File Transfer Protocol. It was designed as a subsystem of SSH version 2, and the OpenSSH sftp client and sftp-server are what most Linux servers use. So what is SFTP not? It is not FTP: it shares no commands or ports with FTP and needs no FTP server.

The protocol that really is FTP with encryption added is FTPS, which wraps FTP in TLS. FTPS uses the FTP ports and an FTP server, while SFTP needs only SSH.

SFTP vs FTP vs FTPS

ProtocolRuns overUsual portEncryptedLogin
FTPPlain TCP21 plus data portsNoFTP account password
FTPSFTP with TLS21 (explicit) or 990 (implicit)Yes, when TLS is onFTP account password
SFTPSSH22, or the server's SSH portAlwaysSSH user, with a key or password

In any SFTP vs FTP comparison, the deciding point is that plain FTP sends your password and files unencrypted, so anyone on the network path can read them. Use SFTP wherever SSH is available. On cPanel servers, note that the separate FTP accounts you create in cPanel cannot log in by SFTP; SFTP uses the cPanel account's own username. The cPanel port numbers guide lists which ports each service needs.

How to use SFTP from the command line

The sftp client ships with OpenSSH on Linux and macOS, and with the OpenSSH client on Windows 10 and 11. Connect like this:

sftp deploy@203.0.113.10
sftp -P 2222 deploy@203.0.113.10

The second line uses a custom SSH port; note the capital -P. At the sftp> prompt, commands that act on the server have plain names, and their local equivalents start with l:

  • pwd, ls, cd: show, list and change the remote folder.
  • lpwd, lls, lcd: the same on your own computer.
  • put file.zip: upload a file to the current remote folder.
  • get backup.sql: download a file to the current local folder.
  • put -R site and get -R logs: copy whole folders.
  • mkdir, rename, rm, chmod 644 index.php: manage remote files.
  • exit or bye: close the session.

A typical upload session looks like this:

sftp> lcd ~/projects/site
sftp> cd public_html
sftp> put -R assets
sftp> ls -l
sftp> exit

For scripts, put the commands in a file and run sftp -b commands.txt deploy@203.0.113.10. Batch mode needs key login, because it cannot stop to ask for a password.

GUI clients: FileZilla, WinSCP and Cyberduck

If you prefer drag and drop, the common desktop clients all speak SFTP:

  • FileZilla (Windows, macOS, Linux): in Site Manager choose SFTP - SSH File Transfer Protocol, enter the host and port, and set the logon type to Key file to point at your private key. Do not pick "FTP over TLS", which is FTPS.
  • WinSCP (Windows): choose SFTP as the file protocol. It can also use keys loaded in PuTTY's Pageant.
  • Cyberduck (macOS and Windows): pick SFTP in the connection dialog and select your private key.

In every client, the host, port, username and key are the ones you use for ssh.

How to use SCP

The scp command copies files in a single step, with a syntax modelled on cp. A remote path is written as user@host:path. Here is how to scp in the common cases:

# upload a file
scp site.zip deploy@203.0.113.10:/home/deploy/

# download a file into the current folder
scp deploy@203.0.113.10:/var/log/nginx/error.log .

# copy a folder recursively
scp -r assets deploy@203.0.113.10:/var/www/site/

# custom port, specific key, keep times and modes
scp -P 2222 -i ~/.ssh/id_ed25519 -p backup.tar.gz deploy@203.0.113.10:/home/deploy/

scp command options worth knowing

  • -r copies directories recursively.
  • -P port sets the SSH port. It is a capital letter because lowercase -p preserves modification times, access times and file modes. ssh itself uses lowercase -p for the port, which catches many people out.
  • -i keyfile chooses the private key.
  • -O forces the legacy SCP protocol, for servers without SFTP.

Since OpenSSH 9.0, scp uses SFTP underneath

OpenSSH 9.0, released in April 2022, made SFTP the default transport for scp, replacing the legacy scp/rcp protocol. The command line is unchanged, but there are two practical effects. First, you no longer need to add extra quotes around spaces or wildcards in remote filenames, and doing so can now make the copy fail. Second, the server needs its SFTP subsystem enabled. Remote paths that start with ~ depend on the server's sftp-server supporting path expansion, which OpenSSH added in 8.7, so on older servers use a full path such as /home/deploy/. If you meet an old server that only speaks legacy SCP, add -O.

rsync over SSH for large or repeated transfers

rsync sends only the parts of files that changed, which makes it far quicker than SFTP or SCP for redeploying a site or refreshing a backup copy. It uses SSH as its transport:

rsync -avz --dry-run site/ deploy@203.0.113.10:/var/www/site/
rsync -avzP -e 'ssh -p 2222' site/ deploy@203.0.113.10:/var/www/site/

-a recurses and keeps permissions and timestamps, -z compresses, and -P shows progress and keeps partly sent files so a rerun can resume. The trailing slash on site/ copies the folder's contents rather than the folder itself. Run with --dry-run first, especially before adding --delete. rsync must be installed on both ends.

Use SSH keys instead of passwords

SFTP, SCP and rsync all authenticate exactly as ssh does, so one key covers all of them. Create a key once on your computer and add the public half to the server:

ssh-keygen -t ed25519
ssh-copy-id deploy@203.0.113.10

ssh-copy-id is not included with the Windows OpenSSH client; on Windows, paste the contents of your .pub file as a new line in ~/.ssh/authorized_keys on the server instead. Never share the private key, the file without .pub.

On cPanel you can generate or import keys under Security, SSH Access, then authorise the public key there. With a key in place you can turn off password login on a VPS, and scripted transfers no longer need a stored password.

Port 22 or a custom port

SFTP has no port of its own: it listens wherever sshd does, which is port 22 unless the administrator changed it. If SSH runs on another port, every tool needs telling: sftp -P, scp -P, ssh -p, rsync -e 'ssh -p N' and the port field in your GUI client. To avoid typing it each time, add a Host block with a Port line to ~/.ssh/config; the OpenSSH tools all read it. If a connection is refused or times out, work through SSH connection refused: causes and fixes.

Permissions and ownership after upload

Files arrive owned by the user you logged in as. On a cPanel account that is your account user, which is what you want. On a VPS, files uploaded as deploy may not be readable or writable by the web server user, so fix ownership with chown or put both users in a shared group. Typical web permissions are 644 for files and 755 for folders:

find /var/www/site -type d -exec chmod 755 {} +
find /var/www/site -type f -exec chmod 644 {} +

Double-check the path first, and re-add execute permission to any scripts afterwards.

Never use 777 to make an error go away; it lets any process on the server change your files. A 403 error straight after an upload is often a permissions problem, covered in the 403 Forbidden guide.

SFTP and SCP on Bigdomainhost

On Web & cPanel hosting, SSH access is available on request, so ask support to switch it on before you use SFTP or SCP. Until then, cPanel's File Manager handles uploads in the browser. When SSH is on, log in with your cPanel username, not an FTP account.

A Linux KVM VPS includes SSH with full root access, in Mumbai (BOM-1) or Delhi NCR (DEL-1). If you paste your SSH public key at order time, password login is disabled from the first boot, so SFTP and SCP work with that key straight away. The panel's per-instance firewall denies inbound traffic except SSH on port 22, so if you move SSH to a custom port, open that port in the panel firewall first. The VPS quickstart covers keys and first login. For help, call +91 75994 50220 during IST hours, WhatsApp the same number at any time, or email support@bigdomainhost.com.

Sources (checked )

Answers

Frequently asked questions

Still unsure? Call +91 75994 50220 or write to support@bigdomainhost.com — a human replies in IST hours.

What does SFTP stand for?

It is short for SSH File Transfer Protocol. Because it runs as a subsystem of SSH, it shares the login, keys and port of an SSH session, normally port 22. Despite the name, it is not FTP with security bolted on; that is FTPS, which wraps FTP in TLS and needs an FTP server.

SFTP vs FTP: which should I use?

Use SFTP whenever the server allows SSH. Plain FTP sends your password and files unencrypted, so anyone on the network path can read them, and it needs extra data ports through firewalls. SFTP encrypts everything over a single SSH connection. Fall back to FTPS, not plain FTP, only if SSH is not available on your account.

How do I use SCP with a different port?

Add a capital -P followed by the port number, for example scp -P 2222 file.zip user@host:/home/user/. Lowercase -p in scp preserves file times and modes instead. The ssh command uses lowercase -p for the port, so it is easy to mix them up. You can also set the port once in a Host block in ~/.ssh/config.

Is SCP deprecated?

The scp command is not going away, but the old SCP protocol behind it has been replaced. Since OpenSSH 9.0, scp uses the SFTP protocol by default while keeping the same command syntax. If you connect to an old server that does not support SFTP, add -O to force the legacy protocol. For syncing large folders, rsync over SSH is usually better.

Can I use SFTP on cPanel hosting?

Yes, if SSH access is enabled on your account. Use the server's hostname, the SSH port and your cPanel username with a key or password. FTP accounts created inside cPanel cannot log in by SFTP. On Bigdomainhost Web and cPanel hosting, SSH access is available on request from support.

Support that picks up the phone.

In IST hours, in Hindi or English, and WhatsApp replies fastest at any time. Sales, migration and emergencies all reach the same engineers. No offshore queue, no 48-hour first reply.

Need cPanel or WHM with the ports already sorted?

Web & cPanel hosting comes with cPanel ready to log in to, reseller hosting adds white-label WHM, and a KVM VPS can have cPanel & WHM pre-installed. Call +91 75994 50220 or email support@bigdomainhost.com.