Use ssh authentication in linux without entering a password to access another machine

Source: Internet
Author: User

In linux, if you use ssh authentication and do not enter a password to access another machine, LINUX programmers will encounter remote login issues in their daily work. Is it annoying to enter a password every time. www.2cto.com. I am here to figure out how the ssh certificate works! In linux, ssh authentication is used, and access to another machine without a password is usually used to log on to another machine through ssh. ssh authentication is performed on each machine, in this way, you do not need to enter a complicated password every time. There are two machines: server_1 and server_2, both of which are: work To work Account: su-work run: ssh-keygen-t rsa (Press enter all the way) command output: www.2cto.com Enter file in which to save the key (/home/work /. ssh/id_dsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in/home/work /. ssh/id_dsa. your public key has been saved in/home/work /. ssh/id_dsa.pub. the key fingerprint is: 32: 21: e1: 3 B: 7d: 6e: de: 4b: 39: da: af: 38: fe: 90: 40: 61 is generated in the/home/work directory. ssh implicit directory, enter these directories to generate two files: id_dsa ------------ private key file id_dsa.pub ------------ copy the id_dsa.pub file to the public key file. The file name is: authorized_keys2 and change the authorized_keys2 attribute to 600. That is, the file owner has the read and write permissions. The group users and other users are prohibited from reading and writing. Run the following command: code: cp id_dsa.pub authorized_keys2 chmod 600 authorized_keys2 also performs the above operations on server_2. The next step is to implement real ssh authentication:/home/work/on server_1 /. copy the id_dsa.pub public key file under the ssh directory to/home/work/of server_2 /. ssh Directory (Note: Do not overwrite id_dsa.pub of server_2 and change the name when copying it), for example, code: [work @ server_1. ssh] $ scp id_dsa.pub in server_2/home/work /. the following file is available in the ssh Directory: authorized_keys2 id_dsa id_dsa.pub server_1.pub command: Code: cat server_1.pub> authorized_keys2 (Be sure to use the append operation ">" not available "> ") this completes the ssh authentication from server_1 to server_2. Log on to server_2 directly using the command code: ssh, instead of entering the password. Perform the same operation as server_2 to server_1.

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.