SSH免密码登陆

来源:互联网 发布:it软件开发工程师 编辑:程序博客网 时间:2024/04/28 18:52

    


     在linux安装hadoop是为了以后操作方便可以进行免密码设置

       1 . 在Xshell 输入 cd 回到当前用户界面

        2  输入下面命令

        ssh-keygen -t rsa  "" 输入这个命令后一直回车就可以了

       [root@hadoop ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
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:
b4:75:7a:87:6b:48:4a:48:39:e4:6c:a3:11:fe:ad:38 root@hadoop
The key's randomart image is:
+--[ RSA 2048]----+
|    . .          |
|   . = .         |
|    o O . . .    |
|     * * o o .   |
|    . o S o o .  |
|     . o o o o   |
|    E . . . o    |
|     .     .     |
|                 |
+-----------------+  

出现如上所示,基本上一直按enter

    2  将生成的公钥id_rsa.pub 内容追加到authorized_keys(执行命令:cat id_rsa.pub >> authorized_keys

       [root@hadoop ~]# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

     安全起见,你可以退出linux再以root登陆进来一下,我是没做这个步骤

0 0