ssh 192.168.21.90
2 执行命令
ssh-keygen -t rsa
[root@fedora14ip90 ~]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): twoServer Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in twoServer. Your public key has been saved in twoServer.pub. The key fingerprint is: 6e:0c:30:81:93:81:d3:53:0b:77:88:8d:53:5a:5a:6d root@fedora14ip90 The key's randomart image is: +--[ RSA 2048]----+ | ooXBo. | |o XBo+E | | .o++. | | o | | . S | | + | | + | | . | | | +-----------------+ [root@fedora14ip90 ~]#
在这个过程中输入文件名[随意即可],还有密码[随意即可]
3 到密钥文件夹下面去
引用
[root@fedora14ip90 .ssh]# cd /root/.ssh/
4 复制密钥到需要无密码访问的电脑上,有scp命令即可
scp id_rsa.pub [email protected]:/root/
scp [文件] [无密码访问的电脑的用户名(我这儿是root)]@[无密码访问的电脑的ip,不用多说]:[无密码访问的电脑的目标文件夹]
这个过程会提示输入密码,输入即可
5 登录到需要无密码访问的电脑上执行命令
cat /root/id_rsa.pub >> ~/.ssh/authorized_keys
6 成功
附:
如果需要快速的实现上面的步骤,实现A机器ssh登录B机器时候不需要密码
1 在A机器上输入命令
ssh-keygen -t rsa -P '' ~/.ssh/id_rsa
2 把生成的文件~/.ssh/id_rsa.pub拷贝到B机器上,然后做相应的操作把~/.ssh/id_rsa.pub文件内容追加到~/.ssh/authorized_keys后面