Configuration of public key authentication mode between SSH servers

Source: Internet
Author: User

Objective

The project needs to write scripts to upload or download files between servers, but there is no relevant server to test the script, so proceed to install two server, and then use the relevant SSH commands to configure the server public key authentication login.

Steps

1. Install two Linux servers under the VM box and use the bridged network type so that the two servers will have their own independent IP

2. On the current server using SSH command to connect to another server, because the public key authentication login is not configured, this is required to enter password to log in

Command: SSH [USER]@[HOSTNAME|IP]

Example: SSH [email protected]

A. The system will prompt you to continue the connection because it is the first connection

    

B. After you enter Yes, you are prompted for password, and the. SSH directory is automatically created under the current user's home directory, and then the Know_hosts file is created below this directory to store information about the target server

    

    

C. After entering password, connect to the target server, you can use the command Ls-al to view the content

    

D. Use the exit command to disconnect

    

3. Configure the Public key authentication login, first use the Ssh-keygen command to create the current server's public and private keys

Command: Ssh-keygen

The system will prompt for the key store directory and key name, if you do not want to enter, press ENTER, the system will use the default directory and key name

Default directory and secret key name:/home/ftpiosh/.ssh/id_rsa,/home/ftpiosh/.ssh/id_rsa.pub, a public key and a private key

    

    

4. Use the Ssh-copy-id command to copy the current server's public key to the appropriate directory for the target server

Command: Ssh-copy-id [User]@[host Name|ip]

Example: Ssh-copy-id [email protected]

A. The system prompts for a password, enter the password, back to display a key added successfully

    

    

B. Target server view public key content

The public key is stored in the/home/ftpiosh/.ssh/authorized_keys file

    

5. Verify the Public key authentication login

Command: SSH [USER]@[HOSTNAME|IP]

Example: SSH [email protected]

The system will log in directly without the need to enter password

    

The above is purely a personal point of view, if there is wrong, please correct me!

  

Configuration of public key authentication mode between SSH servers

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.