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

linux下 ssh 实现无需密码的远程登陆

2013-09-16 13:27 549 查看
主机A(OpenSUSE12.1):119.78.222.95
主机B (Fedora16): 202.122.25.36

1.主机A:生成秘钥对id_rsa和id_rsa.pub

linux-9juc:~ # ssh-keygen -t rsa
Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again: Enter
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:Enter
52:65:a0:7a:9a:42:55:a7:83:eb:d1:a0:f6:2a:e3:cf root@linux-9juc
The key's randomart image is:Enter
+--[ RSA 2048]----+
| . o.o |
| o + o |
| + + . |
| o = o |
| + + + S |
| o o = . |
| . = |
|o .o |
|.+oE |
+-----------------+

2.将主机A上生成的秘钥拷贝到主机B
linux-9juc:~/.ssh # ssh-copy-id -i id_rsa.pub root@202.122.25.36

3.重新登陆
linux-9juc:~/.ssh # ssh root@202.122.25.36
Last login: Mon Sep 16 13:18:57 2013 from 202.122.25.36
成功
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux 密码 ssh private public