Ubuntu 设置 SSH 通过密钥登录

Published on with 0 views and 0 comments

服务器版本: Ubuntu 20.04.5 LTS

制作密钥对

ssh-keygen

安装公钥

cd .ssh/
cat id_rsa.pub >> authorized_keys
chmod 600 authorized_keys
chmod 700 ~/.ssh/

下载私钥

设置ssh

编辑配置文件

vim /etc/ssh/sshd_config

进行如下设置

RSAAuthentication yes
PubkeyAuthentication yes
PasswordAuthentication no

最后,重启 SSH 服务

service sshd restart