Linux SSH 无密码登录

时间:2023-03-09 09:23:28
Linux SSH 无密码登录

1. ssh-keygen -t rsa

2. scp root@ip:/root/.ssh/id_rsa.pub ./id2

3. cat id2 >> authtorized_keys

4. systemctl restart sshd

5. switch to another machine, ssh root@ip

在另一机器上重复以上操作, 其中最关键的是2,3.  一定要用scp 拷贝文件后,通过>>复制秘钥。

而不能通过复制粘贴直接在两个authorized_keys文件中拷贝。否则无效。