Scenario: server A uses ssh to log on to server B without any special settings. If sshhost. B is used, A Password prompt is displayed, asking you to enter the Password. How can I enter the password without manual input? Solution: generate an ssh public key and private key [www.linuxidc.com@login1.cm3.ssh] $ ssh-keygen-tdsaGeneratingpublicprivatedsakey
Scenario: server A uses ssh to log on to server B. If you use ssh host. B without any special settings, the system prompts Password: enter the Password. How can I enter the password without manual input?
Solution:
- Generate an ssh public key and Private Key
- [Www. linuxIdC.com@login1.cm3. ssh] $ ssh-keygen-t dsa
- Generating public/private dsa key pair.
- EnterFileInWhichTo save the key (/home/qingxu/. ssh/id_dsa ):
- Enter passphrase (empty for no passphrase ):
- Enter same passphrase again:
- Your identifiCatIon has been savEdIn/home/qingxu/. ssh/id_dsa.
- Your public key has been saved in/home/qingxu/. ssh/id_dsa.pub.
- The keyFingerPrint is:
- Ba: 43: 5b: 8e: 80: 50: 5b: 88: f1: 01: 99: 1a: c8: 73: 68: AB www.linuxidc.com@login1.cm3
Here-t dsa indicates that the dsa encryption method is used. After you press enter, you will be asked to enter the private key. Finally, two files, id_dsa and id_dsa.pub, are generated under the. ssh directory, indicating the private key and Public Key respectively.
Copy the public key to the machine B you want to log on to, and append the id_dsa.pub content to the authorized_keys file under the. ssh directory of B.
- Cat id_dsa.pub>>Authorized_keys
In this case, server B has two files: id_dsa.pub and authorized_keys.
In this case, we can log on to server B through ssh host. B without reminding the Password. At this time, you will still see such information.
- Www.linuxidc.com@login1.cm3 ~ $ Ssh host. B
- The authenticity of host 'host. B (xxxxxx) 'can't be established.
- DSA key fingerprint is b9: d9: d6: 69: c0: e5: bd: 6d: c8: 89: 43: 8a: a5: d6: ef: a4.
- Are youSuRe you want to continue connecting (yes/no )?
If yes is input, A known_hosts file is generated in the hosts file of server A. The file is used by A to access the server: if the public key of server B is inconsistent with that of the local known_hosts, you will be reminded whether to connect to the server B. Generally, once entered, it will not be prompted in the future.
The following information is displayed:
- Enter passphrase for key'/home/qingxu/. ssh/id_dsa ':
You still need to enter the private key. In the future, no matter how many times you log in, you will be reminded to enter the private key, which does not meet our requirements. What should we do?
- Use ssh-agent and ssh-DdManage keys
Ssh-agent is used to manage keys. ssh-add is used to add keys to the ssh-agent. SSH can communicate with the ssh-agent to obtain keys, so that you do not need to enter the password manually.
eval `ssh-agent` ssh-add Enter passphrase for /home/qingxu/.ssh/id_dsa:
However, it is recommended that you set this parameter once for each login.CommandPut in ~ /. Bash_profile.
In addition, you can use keychain to process this step. For details, refer:
Http://www.linuxidc.com/Linux/2011-08/39871.htm
Http://www.linuxidc.com/Linux/2011-08/39872.htm