Set password-less ssh and linuxssh in linux

Source: Internet
Author: User

Set password-less ssh and linuxssh in linux

Ssh Configuration

Host A: 10.0.5.199

Host B: 10.0.5.198

You need to configure host A to log on to host A and host B without A password.

First, make sure that the firewall of all hosts is disabled.

Run the following command on host:

1. $ cd ~ /. Ssh

2. $ ssh-keygen-t rsa ------------------ press the Enter key until the generated key is saved in the. ssh/id_rsa file according to the default options.

3. $ cp id_rsa.pub authorized_keys

After this step, you can log on to the local machine without a password, that is, ssh localhost, without entering the password.

4. $ scp authorized_keys summer@10.0.5.198:/home/summer/. ssh ------ copy the generated authorized_keys file to host B.

5. $ chmod 600 authorized_keys

Go to the. ssh directory of host B and change the permission of the authorized_keys file.

(4 and 5 can merge one step, execute: $ ssh-copy-id-I summer@10.0.5.198)

 

After completing the preceding steps, you can initiate an ssh connection from the host a to the host a and B. You only need to enter the password for the first login and will not need it later.

 

Possible problems:

1. During ssh Login, the following error occurs: "Agent admitted failure to sign using the key".

Run: $ ssh-add

Forcibly Add the private key.

2. if no error message is displayed, you can enter A password to log on, but you cannot log on without A password on the connected host (for example, if A initiates an ssh connection to B, it will be on B) perform the following steps:

$ Chmod o-w ~ /

    $chmod 700 ~/.ssh

$ Chmod 600 ~ /. Ssh/authorized_keys

3. If you still cannot log on without a password after step 1, try the following:

$ Ps-Af | grep agent

Check whether the ssh proxy is enabled. If enabled, kill the proxy and run the following command to re-open an ssh proxy. If not, run the following command:

$ Ssh-agent

If the problem persists, run the following command to restart the ssh service.

$ Sudo service sshd restart

4. "cocould not open a connection to your authenticationh agent" prompt when executing ssh-add, but failed


For SSH password-less access in linux, follow the instructions on the Internet

Machine A creates A key
Ssh-keygen-t rsa copies the key of server A to server B.
Scp/root/. ssh/id_rsa.pub B _ip:/root/. ssh/authorized_keys2 enter the password, and the copy is complete. Machine B creates a key
Ssh-keygen-t rsa: copy the key of server B to a file.
Cat/root/. ssh/id_rsa.pub>/root/. ssh/authorized_keys2 copy the key file to machine.
Scp/root/. ssh/authorized_keys2 A_ip:/root/. ssh/authorized_keys2

Linux ssh password-less Login

You need to modify the watching symbol in the/etc/ssh/sshd_config file to remove the following three lines :#

Vi/etc/ssh/sshd_config remove the three rows #
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile. ssh/authorized_keys
Restart the sshd service.

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.