SSH public keys of a user#
Over SFTP a user can log in with a key instead of a password. The user keeps the private key; the server is given the public key and lets in whoever proves that they hold the private one. The public keys of a user are set on the Restrictions tab of the User Manager.
List of paths to trusted public SSH key files#
"This user is allowed to login using any of these keys." Add + adds a line. A line names a public key file on the server machine: the file the user's key program made, usually ending in .pub.
- Put the public key files in a folder of the server that users cannot reach.
- A user can have several keys: one per device, or an old and a new one while a key is being replaced.
- Take a line away to take that key's access away. The other keys go on working.
Only the public key ever comes to the server. Do not accept a private key from a user, and do not store one for them.
Key and password together#
| Setting | What it does |
|---|---|
| Require public key and password for authentication. | a login needs both: the key and the password. A stolen key file alone is then not enough. |
| Require public key and keyboard interactive for authentication. | a login needs the key, and then an answer typed at a prompt. That is how a one-time code is asked for over SFTP: see Two factor OTP/SMS in Setup. |
With neither ticked, a user who has keys listed may log in with a key or with the password. To allow keys only, give the account a long random password that nobody knows.
Setting a user up#
- The user makes a key pair, with
ssh-keygenor their SFTP program, and sends you the public key. - Save it as a file on the server, such as
keys/alex.pubin the server's folder. - Add + the path of that file, and Save.
- The user connects with their private key.
If it does not work, open the user's session in Connected users: its log names the key that was offered and says why it was not accepted. The usual reasons are a path with a typing mistake, a file that holds the private key instead of the public one, and a key in a format of another program.
For everybody at once#
The list is inherited like every card. A pattern in the path can stand for the user's name, so that one line on default serves all users: each user's key is then looked for in a file named after them.