File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 14
14
- 在 A 机器上输入命令:` ssh-keygen `
15
15
- 根据提示回车,共有三次交互提示,都回车即可。
16
16
- 生成的密钥目录在:** /root/.ssh**
17
+ - 写入:` cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys `
18
+ - 测试:` ssh localhost `
17
19
18
20
19
21
## 把 A 的公钥发给 B
23
25
24
26
## 测试 A 免密登录到 B
25
27
26
- - 在 A 机器上输入命令:` ssh -p 22 root@192.168.1.105 ` ,则会相应登录成功的提示
28
+ - 在 A 机器上输入命令:` ssh -p 22 root@192.168.1.105 ` ,则会相应登录成功的提示
29
+
30
+ -------------------------------------------------------------------
31
+
32
+ ## 如果是用 pem 登录的话,用 ssh-copy-id 是无法使用的
33
+
34
+ - 先保存 A 的 pub 到本地:` sz /root/.ssh/id_rsa.pub `
35
+ - 登录 B 机子:` cd /root/.ssh/ `
36
+ - 如果 B 机子没有 authorized_keys 文件则创建:` touch /root/.ssh/authorized_keys `
37
+ - 设置权限:`chmod 600 /root/.ssh/authorized_keys `
38
+ - 上传 pub 文件到 B 机子,并在 B 机子上执行:` cd /root/.ssh/ && cat id_rsa.pub >> authorized_keys `
39
+
40
+
41
+
You can’t perform that action at this time.
0 commit comments