Answer the question
In order to leave comments, you need to log in
How to make authentication for sFTP (ssh) user by key file?
Hello!
Installed NGINX, folder with hosts /var/www/html/site.ru/.
Added to /etc/ssh/sshd_config at the end:
Match User ftp
ForceCommand internal-sftp
PasswordAuthentication yes // хочу сделать no
#AuthorizedKeysFile /home/danforth/.ssh/sftp_authorized_keys // путь к файлу с публичным ключем
ChrootDirectory /var/www/
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no
/home/danforth/.ssh/sftp_authorized_keys
is ftp owner and group, and has read/write access only. Oct 16 12:52:17 quasar sshd[23847]: User ftp authorized keys /etc/ssh/authorized_keys/ftp is not a regular file
Match User ftp
ForceCommand internal-sftp
PasswordAuthentication no
AuthorizedKeysFile /etc/ssh/authorized_keys/%u .ssh/authorized_keys
ChrootDirectory /var/www/
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
/etc/ssh/authorized_keys/ftp/.ssh/authorized_keys
/etc/ssh/authorized_keys/ftp/.ssh/authorized_keys
/etc/ssh/authorized_keys/ftp/
/etc/ssh/authorized_keys/%u/
Answer the question
In order to leave comments, you need to log in
In general, it worked with the following config:
namei -mo /etc/ssh/authorized_keys/ftp/.ssh/authorized_keys
drwxr-xr-x root root .
drwxr-xr-x root root authorized_keys
drwxr-xr-x ftp ftp ftp
drwx------ ftp ftp .ssh
-rw------- ftp ftp authorized_keys
Match User ftp
ForceCommand internal-sftp
PasswordAuthentication no
AuthorizedKeysFile /etc/ssh/authorized_keys/ftp/.ssh/authorized_keys
ChrootDirectory /var/www/
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question