昨天不小心把本地VPS的SSH连接密钥删除了,导致没有办法SSH练级VPS,想到VPS的BT还能运行,就想到重新更新用户密钥。操作相当简单
1、利用xagent先生成新的公钥和密钥
2、打开BT面板,文件到用户目录,root为/root,ubuntu为/home/ubuntu,opc为/home/opc,上传公钥id_rsa.pub,id_rsa确保权限700
3、到计划任务添加新的脚本任务,以下为root用户,其他用户请变更路径
cd /root/.ssh && cat id_rsa.pub >> authorized_keys
4、修改authorized_keys权限为600,可以文件那里修改,也可以修改脚本任务,用chmod 600 /<path>/authorized_keys
,最后确保.ssh文件夹是700权限
5、确认ssh的登陆方式,打开/etc/ssh/sshd_config文件,确保一下项目
RSAAuthentication yes
PubkeyAuthentication yes
PermitRootLogin yes
#用密钥登陆成功后,在修改禁用密码登陆 without-password
PasswordAuthentication no
6、最后重启ssh,修改计划任务service sshd restart
通过以上操作后,就可以用新的密钥ssh登陆了,记得把脚本任务删除
评论已关闭