密钥登录远程服务器

 

  1. RSA私钥及公钥生成
    1. ssh-keygen -b 2048 -t rsa
    2. Enter file in which to save the key:

    3. Enter passphrase (empty for no passphrase):

    4. Enter same passphrase again:

  2. 上传公钥到服务器端
    1. scp  {local_id_rsa.pub_path}   {remote_host_ip}:{destination_path}
  3. 服务器端配置
    1. cat {destination_path} >> ~/.ssh/authorized_keys
    2. chmod 700 ~/.ssh

    3. chmod 700 ~/.ssh/authorized_keys
    4. vim /etc/ssh/sshd_config
      删除RSAAuthentication和PubkeyAuthentication前的'#'号

      RSAAuthentication yes

      PubkeyAuthentication yes

       

    5. 重启ssh
      /etc/init.d/sshd restart
原文地址:https://www.cnblogs.com/03-tornado/p/4968616.html