Linux SSH Key Automatic login

Source: Internet
Author: User
Tags scp command

In the development, often need to ssh from one host to another host, each time need to lose login/password, very cumbersome.
Use the key to log in, you can not enter the user name and password

Implementing a password- free login from host A to Host B requires the following steps:
1. Execute command "ssh-keygen-t RSA" in Host a "~/.ssh/" (build process, all the way to enter), generate two files Id_rsa and id_rsa_pub, these two files are actually a key pair, Id_rsa is the private key, Id_rsa_pub is a public key;
2. Copy the file id_rsa_pub from Host a (can use SCP command) to Host B "~/.ssh/" directory;
3. Log on to Host B, enter the "~/.ssh/" directory and add the Id_rsa_pub file from the host to the file "Authorized_keys" tail (cat Id_rsa_pub>>authorized_keys), if the file "Authorized_keys" does not exist, it is created; the "~/.ssh/authorized_keys" permission is at least 600;

4. From Host a login Host B, the first time when the Host B to automatically set the Known_hosts file, so you need to enter Yes, no need for the future;

P.S. Of course, you log in to host A and Host B with the same user name


Configure the user's public key login, configure the Authorized_keys incredibly has been not effective, so Google, found that the original is because. SSH directory and the permissions of the following files caused by the problem, because the permissions of the directory has exceeded the requirements of sshd permissions.

If you want the SSH public key to take effect, at least two of the following conditions will be met:
1). SSH directory permissions must be
2). ssh/Authorized_keys file permissions must be 600




Icing on
Assuming that your username is user, the key login Host B has been set. Then you can define an alias in the shell configuration file (e.g.. BASHRC)
Alias b= ' ssh [email protected] '
After each time you start the shell terminal, enter B, return, directly on the SSH login to Host B.

http://blog.csdn.net/yasaken/article/details/7420093

Linux SSH key automatic login (GO)

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.