SSH password-free alias login

Source: Internet
Author: User
Tags ssh account

SSH login with no password to use the public and private keys. Linux can be used to generate a public/private key pair with Ssh-keygen, below I take CentOS as an example.
Host A (192.168.0.225), B (192.168.0.221). Now want to a through SSH password-free login to B.

1. generate a public/private key pair under the a machine.

[email protected]. ssh]# ssh-keygen-t RSA

Then hit three times to enter .

It generates the. SSH directory under/root, with Id_rsa and id_rsa.pub under SSH.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/58/97/wKiom1S0zq7ARrJQAADAq09Cses739.jpg "title=" Qq20150113155316.jpg "alt=" Wkiom1s0zq7arrjqaadaq09cses739.jpg "/>
2. Copy the id_rsa.pub under the A machine to B machine, in the. ssh/authorized_keys file of B machine, I use SCP to copy. (This step requires a password for b)

[email protected]. ssh]# SCP id_rsa.pub [email protected]/root/

Since there is no password-free login, enter the password.

3.The B machine adds the id_rsa.pub copied from a machine to the. ssh/authorzied_keys file.

[email protected] ~]# cat id_rsa.pub >>. Ssh/authorized_keys
[email protected] ~]# cat id_rsa.pub >>. Ssh/authorized_keys

[Email protected] ~]# chmod Ssh/authorized_keys

Authorized_keys's permission.

4.a machine login B machine.

[email protected]. ssh]# ssh 192.168.0.225
The first time you log in is when you want to enter Yes.

Now a machine can be no password login B machine.

5. alias Login

usually using SSH to connect to a remote server, you typically enter the following command:
SSH [email protected]-P Port
If you have more than one SSH account, especially like I like in the terminal directly SSH login, do not PuTTY, SECURECRT, such as the SSH client, to remember the parameters of each SSH account, it is how the egg hurt things.
Fortunately, SSH provides an elegant and flexible way to solve this problem by using the SSH User Profile config to manage the SSH session. The user profile for SSH is placed in the current user root directory. Ssh/config is written as follows: (alias is www)

Host www
HostName 192.168.0.225
Port 22
User Root
Identityfile/root/.ssh/id_rsa

With these configurations, you can use SSH to log on to the server:

[email protected]. ssh]# ssh www

The above is completed the password-free alias login


SSH password-free alias login

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.