您好,欢迎来到 - 67学习网 - http://www.67xuexi.com !

SSH实现无密码登录

摘要: 除了通过交互式的方式输入用户名和密码以为,SSH中还可以通过一种“公私钥”的方式进行登录,具体的原理为:首先在客户端上创建一对公私钥 (公钥文件:~/.ssh/id_rsa.pub; 私钥文件:~/.ssh/id_rsa)然后把公钥放到服务器上(~/.ssh/authorized_keys), 自己保留好私钥当ssh登录时,ssh程序会发送私钥去和服务器上的公钥做匹配.如果匹配成功就可以登录了具体的实现方法如下:user@ubuntu:~$ ssh-keygen -t rsa -P “”Generating public/private rsa key pair.Enter file in which to save the key (/home/user/.ssh/id_rsa):Created directory ‘/home/user/.ssh’.Your identification has been saved in /home/user/.ssh/id_rsa.Your publi
SSH实现无密码登录,标签:服务器,操作系统教程大全,http://www.67xuexi.com

   除了通过交互式的方式输入用户名和密码以为,SSH中还可以通过一种“公私钥”的方式进行登录,具体的原理为:

  首先在客户端上创建一对公私钥 (公钥文件:~/.ssh/id_rsa.pub; 私钥文件:~/.ssh/id_rsa)

  然后把公钥放到服务器上(~/.ssh/authorized_keys), 自己保留好私钥

  当ssh登录时,ssh程序会发送私钥去和服务器上的公钥做匹配.如果匹配成功就可以登录了

  具体的实现方法如下:

  user@ubuntu:~$ ssh-keygen -t rsa -P “”

  Generating public/private rsa key pair.

  Enter file in which to save the key (/home/user/.ssh/id_rsa):

  Created directory ‘/home/user/.ssh’.

  Your identification has been saved in /home/user/.ssh/id_rsa.

  Your public key has been saved in /home/user/.ssh/id_rsa.pub.

  The key fingerprint is:

  9b:82:ea:58:b4:e0:35:d7:ff:19:66:a6:ef:ae:0e:d2 hadoop@ubuntu

  The key’s randomart image is:

  [...snipp...]

  user@ubuntu:~$ cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys

  主要就是红色的命令,一个是生成公私钥对,类型是rsa,当然也可以是dsa啥的。然后第二条命令就是把公钥放到受信公钥文件里。这个时候使用

  ssh user@localhost

  就可以直接登录不用再输入密码了。当然配置多台机器用scp搞一下就成,这里我就不详说了。


Tag:服务器_操作系统教程服务器,操作系统教程大全电脑教程 - 服务器_操作系统教程

《SSH实现无密码登录》相关文章