您的位置:首页 > 运维架构 > Linux

[Linux] Enable ssh key authentication from one user on client to multiple users on server

2015-11-24 22:22 603 查看
Today, I’m trying to setup ssh key authentication, so I can ssh into my server without typing password.

What caught me is that I can’t get key authentication working for the non-root user on server.

For example, I have user
client
on my client and user
server
and
root
on my server.

client@client # ssh server@server
client@client # ssh root@server


I googled it and found the reference here

To sum it up:

On client machine, generate key-pair

ssh-keygen -t rsa


Copy the content of
.ssh/id_rsa.pub
to
/root/.ssh/authorized_keys
and
/home/server/.ssh/authorized_keys


On server machine, modify
/etc/ssh/sshd_config
, uncomment

RSAAuthentication yes
PubkeyAuthentication yes


THIS STEP IS VERY IMPORTANT!!!

Make sure file permissions on a user’s
/home/server/.ssh
directory must be
700
, and the
/home/server/.ssh/authorized_keys
must be
600


On server machine,
systemctl restart sshd
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: