Ssh configuration password-less login, ssh password login

Source: Internet
Author: User

Ssh configuration password-less login, ssh password login

Premise: machines A and B are all RedHat Linux operating systems and all have user

1. Log On with the user name and run the command on machine.

Ssh-keygen-t rsa

Press enter without a password

Run this operation to generate the id_rsa and id_rsa.pub files under/home/user/. ssh, where id_rsa.pub is the public key.

2. Perform Step 1 on machine B or manually create the/home/user/. ssh folder. Note that the folder permission is set to 700 and id_rsa.pub is copied to machine B.

Scp id_rsa.pub :~ /. Ssh/A. id_rsa.pub

3. Copy A. id_rsa.pub copied to machine B to the authorized_keys file.

Cp A. id_rsa.pub authorized_keys

Or

Cat A. id_rsa.pub> authorized_keys

If you want to access multiple hosts, use> to add them to the authorized_keys file.


Highlights:

A sends the public key to B, not to allow B to access A, but to allow A to access B. Too domineering! That is to say, B cannot keep the public key of A in authorized_keys IN THE. ssh folder. If it is saved, it is to give it to others for access!

If this understanding is reversed, it will always fail!


Refer:

Hadoop installation and configuration-ssh password-less Login
Add to favorites I want to contribute
Hadoop installation and configuration ssh Login Without Password OS: redhat 6 hadoop two nodes, one master and one slave 192.168.0.1 master 192.168.0.2. slave 1. modify the/etc/hosts of each machine and add 192.168.0.1 master 192.168.0.2. slave 2. create hadoop useradd hadoop passwd hadoop on each machine to add permissions to hadoop users. Open the/etc/sudoers file: in root ALL = (ALL) hadoop ALL = (ALL) ALL is followed by hadoop users. in the/home/hadoop/directory of all machines. ssh folder mkdir/home/hadoop 4. generate a key pair ssh-keygen-t rsa on the master machine (Note: ssh and-k There is no space between eygen) one way to press Enter. Go to the. ssh directory cd ~ /. The id_rsa and id_rsa.pub files are generated through ssh. run cp id_rsa.pub authorized_keys 6. copy the authorized_keys file on the Master to the/home/hadoop /. scp authorized_keys slave in the ssh/file :~ /. Ssh 7. Modify the permission for modifying the. ssh directory and authorized_keys (this must be modified, or you still need a password) sudo chmod 644 ~ /. Ssh/authorized_keys sudo chmod 700 ~ /. Ssh under normal circumstances, you can log on to this location through SSH without a password and enter ssh slave for testing.


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>

Follow the hadoop authority guide to configure ssh password-less login, which has never been successful ~~~~~~

1. You can uninstall ssh first. To uninstall ssh, enter one or two commands. The details are unclear.
Reinstall ssh and reconfigure password-less access. The following is a command to configure password-free access:
1: ssh-keygen-t rsa-f ~ /. Ssh/id_rsa
Enter pass phrase. Do not enter any characters. Press enter.
2: cat ~ /. Ssh/id_rsa.pub> ~ /. Ssh/authorized_keys
3: ssh localhost
4: If you want to prompt for a password, modify the password:
Chmod 600 ~ /. Ssh/authorized_keys
2. directly follow the above steps, but if you are prompted to overwrite it.
The second method may have some permission issues. That is, your ssh users cannot read data from other ssh users.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.