I want to be able to allow users to connect to my SFTP server with openssh key which I generated in keygen. How would I accomplish this?
1 Answers
Users should generally connect using their own keys.
I assume you are referring to connecting from the command line, and SFTP uses the SSH protocol. So if the users have ssh-copy-id installed, they will need to copy their public SSH key to .ssh/authorized_keys inside their home directories.
To generate their keys in case they don't already have them, have them run the following command:
$ ssh-keygen -t rsa -b 2048
Then if they have 'ssh-copy-id' installed, use the following command to copy to your server:
$ ssh-copy-id user@host
Otherwise, the following Bash oneliner always works:
$ PUB="$(cat ~/.ssh/id_rsa.pub)"; ssh user@host "mkdir -p ~/.ssh; echo $PUB >> ~/.ssh/authorized_keys; chmod 700 ~/.ssh; chmod 600 ~/.ssh/authorized_keys"
The users should now be able to access your SFTP server using public key authentication, as long as it is enabled in your sshd_config.

- 389
- 3
- 14