How to achieve SSH password-less Login

Source: Internet
Author: User

How to achieve SSH password-less Login

Assume that you are a user "aliceA" on hostA and want to ssh to hostB as user "aliceB", but do not want to enter the password. So, you can refer to this tutorial to achieve ssd password-less login.

First, you need to log on to hostA as the user "aliceA.

Then, use ssh-keygen to generate a pair of rsa Public and private keys. The generated key pairs are stored in ~ /. Ssh directory.

  1. $ ssh-keygen -t rsa

Next, use the following command to create ~ /. Ssh directory. If the. ssh directory already exists on aliceB @ hostB, this step is skipped.

  1. $ ssh aliceB@hostB mkdir -p .ssh

Finally, copy the public key of the user "aliceA" on hostA to aliceB @ hostB to implement password-less ssh.

  1. $ cat .ssh/id_rsa.pub | ssh aliceB@hostB 'cat >> .ssh/authorized_keys'

Since then, ssh from aliceA @ hostA to aliceB @ hostB no longer requires a password. You can also run the ssh-copy-id command to create and copy a directory:ssh-copy-id -i ~/.ssh/id_rsa.pub aliceB@hostB)

Troubleshooting
  1. Even after the key authentication takes effect, you may still need to enter the SSH password. In this case, check the system log (for example,/var/log/secure) to check whether the following exception occurs.

    Authentication refused: bad ownership or modes for file/home/aliceB/. ssh/authorized_keys

    In this case, the failure of key authentication is due ~ The permission or owner of the/. ssh/authorized_keys file is incorrect. Generally, this error occurs if the file is readable to all users except you. Change the file permission in the following way to correct the error.

    1. $ chmod 700~/.ssh/authorized_keys

How to Improve the SSH login authentication speed of Ubuntu

Enable the SSH service to allow Android phones to remotely access Ubuntu 14.04

How to add dual authentication for SSH in Linux

Configure the SFTP environment for non-SSH users in Linux

Configure and manage the SSH service on Linux

Basic SSH tutorial

SSH password-free logon details

This article permanently updates the link address:

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.