当前位置:网站首页>During SSH configuration key login, you need to pay attention to whether the private key is set with a password

During SSH configuration key login, you need to pay attention to whether the private key is set with a password

2022-06-11 02:11:00 Lao Luo who likes playing football

 Insert picture description here

As the title

Recently, you need to configure SSH Log in to the background server to check the log , And then we use SSH Key login method for , Because the key pair ( Public and private keys ) It is generated in the server background management system , And it was applied for some time ago , I forgot that there was a private key filled in the key application passphrase, When using it, I think there is no private key , Therefore, various logins are unavailable due to incorrect configuration , Wasted a lot of time
Some articles on the Internet mention SSH Sign in , Some of the headlines say 《SSH Public key login 》, This can lead to misunderstanding or affect memory SSH The actual process of key login

Key login simply means that we generate a key pair ( Public and private keys ), Then we put the public key on the target server , Then use the key to log in to the target server .
The password for the private key (passphrase) When we generate the key pair, we have the opportunity to set , This setting is optional . Generally, it is better to set it based on security considerations
When a password is set for the private key, it will , Then use the private key ssh To the target server , The terminal will prompt you to enter the password of the private key . If you don't want to enter the password of the private key every time , The simplest is not to set a password . But I don't want to input the password every time ?
So please ssh-agent It's out of the way (PS: ssh-agen There is also a powerful private key forwarding function , It is used for springboard login , For details, please see the article I share below )

#  Turn on agent
eval `ssh-agent`
#  Add the private key to the cache ,add The password for entering the private key will be provided when entering 
ssh-add  Your private key file 

#  It can be used  -l  Parameters to see , Those private keys were added , Confirm the upper limit add Whether the private key of 
ssh-add -l

After the above operation , We are in the current SHELL Use ssh Key login eliminates the need to enter the private key password every time

SSH Login mode

  1. Login with account number and password
  2. Key login
  3. Certificate login

Reference article

原网站

版权声明
本文为[Lao Luo who likes playing football]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110100063674.html