SSH installation configuration

1, root user to enter the home directory, and indeed whether the hidden folder .ssh

cd ~
ls -lrta

2, there are, then skip this step; no, execute the following commands

##根据提示输入当前用户密码
ssh localhost
##登录成功后,再次退出
exit
##进入home目录查看 .ssh
cd ~
ls -lrta

3, after successfully generated .ssh directory, execute the following command

##进入目录
cd .ssh
##生成秘钥,ssh-keygen用于生成秘钥,-t 指定秘钥类型为 rsa秘钥(一路回车即可)
ssh-keygen -t rsa

After machining, the production of the private key file id_rsa and public key files in the current directory id_rsa.pub:

4, the cluster configuration (if the stand-alone configuration, skip this step!)
 To complete Step 1 sequentially on other machines in the cluster, steps 2 and 3, generates a public key and private key file id_rsa file id_rsa.pub.

5, the id_rsa.pub file append it to an authorized key file, the command is as follows:

##追加公钥到授权文件中
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys 

If the stand-alone configuration, SSH configuration is now complete! If a cluster configuration, continue with the following steps.

6, a first copying machine authorized_keys file to the second machine, the second machine and the public key to be added authorized_keys file, execute the following commands:

##复制第一台机器的授权文件到第二台机器
scp authorized_keys [email protected]:~/.ssh/
##在第二台机器上执行此命令,将第二台机器的公钥追加到授权文件中
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys 

7, the second copying machine authorized_keys file on a third machine and the third machine are also added to the public key authorized_keys file, execute the following commands:

##复制第二台机器的授权文件到第三台机器
scp authorized_keys [email protected]:~/.ssh/
##在第三台机器上执行此命令,将第三台机器的公钥追加到授权文件中
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys 

 If there are more machines in the cluster, and so on to complete the authorization documents together well. So far ssh configuration, can avoid dense login on any machine configured ssh to the other machines, for the first time will enter the login password!

  • Author: DeepInThought
    Source: https://www.cnblogs.com/DeepInThought
    This article belongs to the author and blog Park total, welcome to reprint, but without the author's consent declared by this section must be retained, and given the original connection in the apparent position of the article page, otherwise the right to pursue legal responsibilities.
  • Guess you like

    Origin www.cnblogs.com/DeepInThought/p/10993166.html