Ssh password-free Login

Source: Internet
Author: User
Tags ssh access

Ssh password-free Login

Recently, I used rsync to process sync from the ssh channel. However, ssh requires a password pair to be used for rsync, and it is also placed into cron auto-dynamic lines, no one can find the password. It will cry ~

Secret generation using ssh-keygen id_rsa, id_rsa.pub

$ Ssh-keygen-t rsa or ssh-keygen-d (dsa)

Send the generated id_rsa.pub to the peer's host using scp. (Password authentication is still required in this process)

$ Scp id_rsa.pub server_hostname :~ /. Ssh/

Redirect to the opposite host

$ Ssh server_hostname

Combine the id_rsa.pub from the authorization with authorized_keys.

$ Cat. ssh/id_rsa.pub>. ssh/authorized_keys

In this way, the sub-account can log on through the key authentication without entering the password.

If there is no. ssh access on the host of the peer, you can create and use it on your own.

######################################## #########################

 

Three steps are required to configure SSH password-less Logon:
1. Generate public and private keys
2. Import the public key to the authentication file and change the permission.
3. Test

1. Generate public and private keys
Shell code
Ssh-keygen-t rsa
The default value is ~ /. Generate two files in the ssh directory:
Id_rsa: Private Key
Id_rsa.pub: Public Key


2. Import the public key to the authentication file and change the permission.
2.1 import Local Machine
Shell code cat ~ /. Ssh/id_rsa.pub> ~ /. Ssh/authorized_keys

2.2 import the server for password-free Login
First, copy the public key to the server.

Shell code scp ~ /. Ssh/id_rsa.pub xxx @ host:/home/xxx/id_rsa.pub
Then, import the public key to the authentication file. This step is performed on the server.

Shell code cat ~ /Id_rsa.pub> ~ /. Ssh/authorized_keys

2.3 Change permissions on the server
Shell code
Chmod 700 ~ /. Ssh
Chmod 600 ~ /. Ssh/authorized_keys

3. Test
Ssh host, the First Login may require yes confirmation, and then you can log on directly.

4. You can directly execute the command
Ssh 10.207.139.62 'hostname'

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.