非root密钥登陆ssh

最后编辑:4 月

ssh-keygen -t rsa -C "xxx@domain" 
# 将生成的密钥放到相应的位置
mkdir /home/username/.ssh 
touch /home/username/.ssh/authorized_keys
# Enter file in which to save the key (/root/.ssh/id_rsa):/home/username/.ssh/id_rsa
cd /home/username/.ssh
cat id_rsa.pub > authorized_keys
# 修改权限
cd ..
chown -R username:username .ssh 
chmod -R 700 .ssh
chmod 600 .ssh/authorized_keys
登陆的用户名为:username 登陆的密钥为/home/username/.ssh/id_rsa的内容

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

[smirking] [hentai] [wounded] [cracker] more »