[Go] Linux Server three-step configuration password-free login

Source: Internet
Author: User

Ssh-keygenGenerates a public and private key pair. Ssh-copy-idCopy the local public key to the remote machine's Authorized_keys file, Ssh-copy-id can also give you the right to the remote machine home, ~./SSH, and ~/.ssh/authorized_keys
First step: Use Ssh-keygen on the local machine to generate the public key private key pair
    1. [Email protected]$ [Note:you is on local-host here]
    2. [Email protected]$ Ssh-keygen
    3. Generating public/private RSA key pair.
    4. Enter file in which to save the key (/HOME/JSMITH/.SSH/ID_RSA): [Enter key]
    5. Enter passphrase (empty for no passphrase): [Press ENTER key]
    6. Enter same passphrase again: [Pess enter key]
    7. Your identification has been saved In/home/jsmith/.ssh/id_rsa.
    8. Your public key has been saved in/home/jsmith/.ssh/id_rsa.pub.
    9. The key fingerprint is:
    10. 33:B3:FE:AF:95:95:18:11:31:D5:DE:96:2F:F2:35:F9 [email protected]
Step two: Use Ssh-copy-id to copy the public key to the remote machine
    1. [Email protected]$ ssh-copy-id-i ~/.ssh/id_rsa.pub remote-host
    2. [email protected] ' s password:
    3. Now try logging to the machine, with "ssh ' remote-host '", and check in:
    4. . Ssh/authorized_keys
    5. To make sure we haven ' t added extra keys so you weren ' t expecting.

Note: Ssh-copy-id writes key to the ~/ . Ssh/authorized_key. File in the remote machine.

Step Three:Log on toRemote machine does not enter password
    1. [Email protected]$ ssh remote-host
    2. Last Login:sun-17:22:33 from 192.168.1.2
    3. [Note:ssh did not ' ask for password.]
    4. [Email protected]$ [Note:you is on remote-host here]

Problems:

    1. Ssh-copy-id-u eucalyptus-i ~eucalyptus/.ssh/id_rsa.pub [email protected]_host

The above is to give Eucalyptus users the right to login without a password

[1]

    1. /usr/bin/ssh-copy-id:error:no identities found

With option-I, when no value is passed or if the ~/.ssh/identity.pub file is inaccessible (not present), Ssh-copy-id displays the above error message (The-I option takes precedence over what will be ssh-add-l)

  1. [Email protected]$ ssh-agent $SHELL
  2. [Email protected]$ ssh-add-l
  3. The agent has no identities.
  4. [Email protected]$ ssh-add
  5. Identity added:/home/jsmith/.ssh/id_rsa (/HOME/JSMITH/.SSH/ID_RSA)
  6. [Email protected]$ ssh-add-l
  7. Ssh-rsa AAAAB3NZAC1YC2EAAAABIWAAAQEASJIEILXFTJ8ASXMA3D8T6JVM79DYBV
  8. ahrtphtypq7kiemunzapnyxshph1tq/ow==/home/jsmith/.ssh/id_rsa
  9. [Email protected]$ ssh-copy-id-i remote-host
  10. [email protected] ' s password:
  11. Now try logging to the machine, with "ssh ' remote-host '", and check in:
  12. . Ssh/authorized_keys
  13. To make sure we haven ' t added extra keys so you weren ' t expecting.
  14. [Note:this have added the key displayed by Ssh-add-l]

[2] Ssh-copy-id should be noted in three small places

    1. default public key: Ssh-copy-id uses ~/.ssh/identity.pub as the default public key file (i.e if no value is pas sed to option-i). Instead, I Wish it uses id_dsa.pub, or id_rsa.pub, or identity.pub as default keys. I.e If any one of them exist, it should copy this to the Remote-host. If or three of them exist, it should copy Identity.pub as default.
    2. The agent has no identities: When the ssh-agent is running and the ssh-add-l returns ' the agent has no identities ' (i.e no keys are added to the ssh-a Gent), the Ssh-copy-id would still copy the message "The agent has no identities" to the Remote-host ' s Authorized_keys entr Y.
    3. Duplicate entry in Authorized_keys: I Wish Ssh-copy-id validates duplicate entry on the Remote-host ' s authorized_keys. If you execute Ssh-copy-id multiple times on the local-host, it'll keep appending the same key on the Remote-host ' s auth Orized_keys file without checking for duplicates. Even with duplicate entries everything works as expected. But, I would like to has my Authorized_keys file clutter free.

[Go] Linux Server three-step configuration password-free login

Related Article

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.