Skip to content

Commit 0a01ab9

Browse files
committed
🚧 SSH
1 parent f981807 commit 0a01ab9

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

markdown-file/SSH-login-without-password.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
- 在 A 机器上输入命令:`ssh-keygen`
1515
- 根据提示回车,共有三次交互提示,都回车即可。
1616
- 生成的密钥目录在:**/root/.ssh**
17+
- 写入:`cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys`
18+
- 测试:`ssh localhost`
1719

1820

1921
## 把 A 的公钥发给 B
@@ -23,4 +25,17 @@
2325

2426
## 测试 A 免密登录到 B
2527

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+

0 commit comments

Comments
 (0)