ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Passwordless SSH Login

2021-04-15 12:05:40  阅读:448  来源: 互联网

标签:Passwordless authorized machine keys SSH Login password dsa ssh


 

Consider two machines A and B. We want to connect machine B from A over SSH. To do so we have to specify password every time we connect. Here, we can create a setup where SSHing can be done without the password prompt.  On connecting machine B from A, ssh won’t ask for password.

Overview of Setup

  • Generate public and private encryption keys on machine A.
  • Authorize machine A in machine B by appending the public key of A in the file authorized_keysof machine B.

That’s it! You can now access (SSH) machine B from A without specifying the password. B has been now authorized to access A without requiring the password.

Detailed Steps

Method 1

  • Login to machine A and execute the following command:
    1 ssh-keygen && ssh-copy-id -i user@B

    The first command generates keys. It will ask for path of the keys and passphrase. Hit Enter key repeatedly to choose the default values.
    The second command adds generated key to B. It will ask for password of user at machine B. And this would be the last time!

Method 2

  • Login to machine A.
  • Generate public and private keys like following:
    1 ssh-keygen -t dsa

    It will ask for path of the keys and passphrase. Choose the default path and no password.
    This will generate files id_dsa.pub and id_dsa in ~/.ssh

  • Browse for the above generated keys and copy the public key, that is id_dsa.pub, to the machine B.
  • Login to machine B.
  • Append the public key of A to the file authorized_keys:
    1 cat id_dsa.pub >> .ssh/authorized_keys

    Note: Create the directory .ssh in your home if it doesn’t exist.
    You can now delete id_dsa.pub from machine B if you want to.

  • Make sure of the permissions of the directory .ssh and the file authorized_keys are read-write only by the targetted user. Otherwise it might not work.
    1 2 chmod 700 .ssh chmod 600 .ssh/authorized_keys
  • Now go back to machine A and SSH machine B. It should not ask for the password.

标签:Passwordless,authorized,machine,keys,SSH,Login,password,dsa,ssh
来源: https://www.cnblogs.com/pinghengxing/p/14661775.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有