SSH key Login-no password to enter

Source: Internet
Author: User

Do a summary of the SSH login class, using a key without password login.


Experimental environment: Two CentOS Release 6.6 (Final) with IP addresses of 192.168.2.3 and 192.168.2.6 respectively


One, on Windows through the Xshell and other remote connected terminal tools:

The implementation steps are:

1. Use the new User Key Generation Wizard under the Tools menu in Xshell to generate the key,

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/1B/wKiom1Vz-j2TFT5eAAHuqhl4X40350.jpg "style=" float: none; "title=" 1.png "alt=" Wkiom1vz-j2tft5eaahuqhl4x40350.jpg "/>

Then choose the appropriate key type and length, we recommend using RSA, length select 2048 bit or more bits.

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "border=" 0 "style=" Background:url ("/e/u261/ Lang/zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650) this.width=650 ; "Src=" http://s3.51cto.com/wyfs02/M00/6E/17/wKioL1Vz-96AKhGfAAF3X1-dKw8478.jpg "title=" 2.png "style=" Float:none; " alt= "Wkiol1vz-96akhgfaaf3x1-dkw8478.jpg"/>

Then click "Next","Next", enter a good distinguished key name, to the user key encryption password I choose not to enter, blank, directly click "Done", so that a private key is generated.

You can view the private key of the key you just generated from the user Key Manager in the Tools menu, and see the properties of the corresponding private key to see its public key.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/1C/wKiom1Vz-j3AXevgAAKlD3k7Xlc765.jpg "title=" 3.png " Style= "Float:none;" alt= "wkiom1vz-j3axevgaakld3k7xlc765.jpg"/>

2. Send the public key to the host to log in.

Copy the contents of the "public key" that you viewed in the previous step, and save it to the. SSH directory under the user's home directory where you want to log in, and name it Authorized_keys.

If there is no such hidden folder under the home directory, you can use the #ssh-keygen-t RSA command to generate it.

3, then we can use the key to log on to this host.

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "border=" 0 "style=" background:url ("/E /u261/lang/zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650) this.width=650, "src=" http://s3.51cto.com/wyfs02/M01/6E/17/wKioL1Vz-96xxskkAACs7DbEFZk571.jpg "title=" 4.png " Style= "Float:none;" alt= "wkiol1vz-96xxskkaacs7dbefzk571.jpg"/>

I put the public key in the root home directory of 192.168.2.3, so the username used to log in is root

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "border=" 0 "style=" Background:url ("/e/u261/ Lang/zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650) this.width=650 ; "Src=" http://s3.51cto.com/wyfs02/M02/6E/1C/wKiom1Vz-yuAEWM-AACpalhBDO8587.jpg "title=" 5.png "alt=" Wkiom1vz-yuaewm-aacpalhbdo8587.jpg "/>

Click OK, pop up the box to enter the password, at this time, we select the following use public key, select the private key corresponding to your key file

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "border=" 0 "style=" Background:url ("/e/u261/ Lang/zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650) this.width=650 ; "Src=" http://s3.51cto.com/wyfs02/M00/6E/17/wKioL1Vz_N_C_gGFAAFkwAN1J5Q981.jpg "title=" 6.png "alt=" wkiol1vz_n_c_ Ggfaafkwan1j5q981.jpg "/>

Click OK again to login to the host without the password key.

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "border=" 0 "style=" Background:url ("/e/u261/ Lang/zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650) this.width =650; "src=" http://s3.51cto.com/wyfs02/M00/6E/17/wKioL1Vz_VzTc2OWAAC2eEzf6zU591.jpg "title=" 7.png "alt=" wkiol1vz_ Vztc2owaac2eezf6zu591.jpg "/>


Second, directly on the Linux command line:


1, using the #ssh-keygen-t RSA command to generate the key, press three spaces to generate a good, there are a lot of information prompted.

The keys generated using this command are stored in the current user's home directory, which generates. SSH's hidden directory, which is typically generated under the directory. Id_rsa, id_rsa.pub, known_hosts

These three files, respectively, correspond to the private key, the public key, and the list of hosts that hold the credentials. Note The permissions for this directory are 700, the private key file is 600 permissions, and it is best not to change the permissions, which may result in unusable.

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "border=" 0 "style=" Background:url ("/e/u261/ Lang/zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650) this.width=650 ; "Src=" http://s3.51cto.com/wyfs02/M01/6E/1C/wKiom1Vz-4qC82ayAAECJhq4Kck173.jpg "title=" 10.png "alt=" Wkiom1vz-4qc82ayaaecjhq4kck173.jpg "/>

2, using Ssh-copy-id to copy the public key to the target host directory user's home directory of the. SSH directory, and to automatically copy the past public key is named Authorized_keys Oh. If there is no directory, it will be generated automatically.

#ssh-copy-i/path/to/publickey [Email protected]

For example, I'm going to use the key to log in to the root of host 192.168.2.6 under 192.168.2.3, so my copy command is this:

#ssh-copy-i/root/.ssh/id_rsa.pub [email protected]

Then there will be some hints Oh, action as required.

# Yes

#输入主机192.168.2.6 root password, then prompts to complete and joins the known_hosts.


3, then we can use the key login host 192.168.2.6 Oh.

Under the command line of the 192.168.2.3

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "border=" 0 "style=" Background:url ("/e/u261/ Lang/zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650) this.width =650; "src=" http://s3.51cto.com/wyfs02/M00/6E/1C/wKiom1Vz-9nA-DOVAAEfT8ZW3wo560.jpg "title=" 8.png "alt=" Wkiom1vz-9na-dovaaeft8zw3wo560.jpg "/>

#ssh [email protected] This command to log in to verify that you can log on using the key.

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "border=" 0 "style=" Background:url ("/e/u261/ Lang/zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650) this.width=650 ; "Src=" Http://s3.51cto.com/wyfs02/M01/6E/17/wKioL1Vz_P6jBiXHAAIwXU47_lg702.jpg "title=" Ed308d88-dc1c-471d-8d06-9e2603821d7b.png "alt=" Wkiol1vz_p6jbixhaaiwxu47_lg702.jpg "/>

Did not enter the password to succeed, using Ifconfig to view the current IP know that the login has been successful.


SSH key Login-no password to enter

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.