VPS设置密钥登录 一键导入公钥到VPS

开启密钥登录 一键导入公钥脚本

如果没有密钥 在vps上申请一个 如果有请忽略

申请密钥

申请密钥对

ssh-keygen -t ed25519 -a 100

安装公钥

cat .ssh/id_ed25519.pub >> .ssh/authorized_keys

私钥设置可读权限

chmod 600 .ssh/id_ed25519

保存好私钥

id_ed25519

一键导入公钥脚本

bash <(curl -sL https://raw.githubusercontent.com/leuxinovo/clearvps/main/sshkey.sh) -g github用户名

把公钥导入到GitHub https://github.com/settings/keys 即可使用脚本一键导入公钥到VPS

设置密钥登录

nano /etc/ssh/sshd_config

进行如下设置: 开启密钥登录:PubkeyAuthentication yes 另外,请留意 root 用户能否通过 SSH 登录: PermitRootLogin yes 当你完成全部设置,并以密钥方式登录成功后,再禁用密码登录: PasswordAuthentication no

最后重启ssh

systemctl restart ssh
免责声明
⏱ 已运行: 加载中...