SSH password-less Logon
SSH (Secure Shell) is a security protocol designed for remote login sessions and other network services.
With SSH, You can remotely log on to other Linux Hosts, but you need to enter a password. If you log on to 10.3.93.213, you must enter a password.
To achieve password-less logon, you can use the ssh-keygen command to generate a public key, and then copy the public key to the host to be remotely logged on.
Enter the ssh-keygen command and press enter three times in a row.
Go to the. ssh folder and you will see two files generated:
Id_rsa.pub is the public key. Use the scp command to copy it to the. ssh folder 10.3.93.212.
If the authorized_keys file of 10.3.93.212 already exists, copy id_rsa.pub and run cat id_rsa.pub> authorized_keys.
SSH 10.3.93.212 again. You can log on without a password.
Ssh does not require a logon password. How can I configure it?
Here is an example:
192.168.1.1 --- client
192.168.1.2 --- slave
First on 192.168.1.1
Ssh-keygen
Generate id_rsa id_rsa.pub
Copy the content in id_rsa.pub
Create the authorized_keys file in the/root/. ssh/directory of 192.168.1.2
Copy the content in id_rsa.pub of 192.168.1.1 to the authorized_keys file.
Then execute ssh-keygen on 1.2.
Copy the content in id_rsa.pub to/root/. ssh/authorized_keys at 192.168.1.1.
Now you can try it!
How to configure ssh password-less login in ubuntu?
There is no space between ssh and-keygen.
Ssh-keygen is used to generate key pairs.
Command:
Ssh-keygen-t dsa-f ~ /. Ssh/id_dsa
After you press enter, you will be prompted to enter the passphrase password, just skip it.
After completion ~ Two new files are generated under the/. ssh/directory, instead of folders.
Id-dsa # Private Key
Id_dsa.pub # public suffix, public Key
Also, your-p command may be confusing.
Man ssh-keygen
-P phrase Provide old passphrase. # The parameter followed by-P is the old password set previously.
-P Change passphrase of private key file. #-p, lowercase p, without parameters, indicates that you want to Change the password
In fact, the ssh section of laruence's private kitchen is very detailed. You can refer to it for details.
I will share with you the process I tried:
# Set key verification
1. Generate a local public key and private key pair
2. Modify the Private Key Permission to 600, which can only be accessed by myself.
3. Upload the public key to the server
4. append the public key content to the/. ssh/authorized_keys file in the home directory of the remote host.
Change authorized_keys to 600
Delete the uploaded public key.
5. Import the new key pair in the local key ring.
The command is as follows:
1.
Ssh-keygen-t rsa
# Enter passphraze in the middle. Do not enter passphraze. enter directly to the end.
Result: a key pair is generated.
Your identification has been saved in/home/Lynn/. ssh/id_rsa.
Your public key has been saved in/home/Lynn/. ssh/id_rsa.pub.
2.
Chmod 600/home/Lynn/. ssh/id_rsa
3.
Cd ~ /. Ssh
Sftp Capricorn@192.168.1.100
Sftp> put id_rsa.pub
Exit
4.
Ssh Capricorn@192.168.1.100
Cat id_rsa.pub>./. ssh/authorized_keys
Chmod 600./. ssh/authorized_keys
Rm id_rsa.pub
Exit
5. # The new private key generated by keygen imported by the client
# Ssh-add-adds private key identities to the authentication agent
Ssh-add
Finished .... Remaining full text>