# SFTP and SCP ports

A listener of the protocol **SFTP/SCP (SFTP://)** answers SSH clients for file transfer: SFTP, and the older SCP. It is made in [IP / Servers](Ports.md). The usual port is 22; a new server listens on 2222, so that it does not collide with the machine's own SSH service.

The listener offers file transfer only. Nobody gets a command line on the server through it.

An SFTP listener has a tab of its own, **SSH**:

![The SSH tab of an SFTP listener](Ports-SFTP/ssh.png)

## Host keys

The key by which the server proves to clients that it is itself. See [SSH host keys, ciphers and key exchange](Ports-SFTP-Keys-and-Ciphers.md).

## Ciphers, MACs and key exchanges

Which algorithms the port offers, as one of four ready sets or as lists of your own: the same page.

## Logging in

| Setting | What it does | New listener |
|---|---|---|
| **Require Password Authentication** | every login on this port needs the password, also one that has shown a key | off |
| **Require Public Key Authentication** | every login on this port needs a key, also one that has given the password | off |
| **Auth timeout** | how long a client may take to log in, in seconds | 30 |

With neither required, a user gets in with a key that is listed for them, or with the password. With both, every login needs both. The same can be demanded for single users instead of the whole port: see [SSH public keys of a user](Users-Restrictions-SSH-Keys.md).

## Sessions

| Setting | What it does | New listener |
|---|---|---|
| **Idle Timeout** | a session that does nothing for this long is closed, in seconds | 300 |
| **Keep-alive interval** | how often the server sends a keep-alive, so that firewalls do not drop a quiet connection, in seconds | 30 |
| **Max Channels Per Connection** | how many channels one connection may open. A client that opens files in parallel uses one each. | 5 |
| **Max Tunnel Channels Per Connection** | the same for port forwarding through SSH | 1000 |
| **Text Encoding** | how file names are read and written | UTF8 |
| **Allow SSH compression** | clients may ask for compression | on |
| **SFTP Welcome Message**, on the General tab | text shown to a client after it connects | empty |

## Performance and compatibility

Leave these as they are unless a client has trouble or the port is very busy.

| Setting | What it does | New listener |
|---|---|---|
| **Max packet length** | the largest packet accepted, in bytes | 70000 |
| **Window Space** | how much a client may send before the server answers | 4096 |
| **Minimum DH Key Size**, **Maximum DH Key Size** | the size of the group in a Diffie-Hellman group exchange. 2048 as the minimum keeps out weak groups. | 2048, Auto |
| **RSA Sha1 Signatures Supported** | accepts the old `ssh-rsa` signature with SHA-1. Only for clients that know no other. | off |
| **Use Asynchronous Threading**, **Max async requests** | answers a client's requests on several threads at once | off, 200 |
| **Transfer Threads**, **Accept Threads**, **Connect Threads** | how many threads serve transfers, new connections and logins | 2 each |
| **Enable debug logging** | writes the SSH conversation to the log, to find out why a client cannot connect. Turn it off again. | off |

## The other tabs

**Advanced** has the switches every listener has, among them the PROXY protocol: see [IP / Servers](Ports.md#advanced). **IP Restrictions**: see [IP restrictions of a port](Ports-IP-Restrictions.md).

## Protection against misuse

The port holds every client to one key exchange request at a time, refuses oversized requests before login, and counts channels against the limits above. A client that hammers the port is banned by the server's rules in [Banning](Prefs-Banning.md).

## When a client cannot connect

| The client says | Usually |
|---|---|
| "no matching key exchange", "no matching cipher", "no matching MAC" | an old client and a strict set: see [the sets](Ports-SFTP-Keys-and-Ciphers.md#the-sets) |
| "no matching host key type" | a client that knows only `ssh-rsa` with SHA-1: **RSA Sha1 Signatures Supported**, or better a newer client |
| "host key has changed" | the server's key file was replaced: see [host keys](Ports-SFTP-Keys-and-Ciphers.md#host-keys) |
| "permission denied" | name, password or key; a user who may not use SFTP: [Protocols a user may use](Users-Restrictions-Protocols.md) |
| it connects, and stalls on big listings | **Use Asynchronous Threading** off, **Max packet length** |

**Enable debug logging** and the user's session log in [Connected users](Admin-Sessions.md) show what was offered and refused.

For the client's side, see [Connecting with SFTP clients](Connect-SFTP.md).
