SSH login without password: Only two simple steps (Linux)

Source: Internet
Author: User
Tags scp command asymmetric encryption

Last updated April 8, 2017Category latest Articles server Security label RSA SSH Key Asymmetric Encryption

If you manage a Linux server, you will know how cumbersome it is to enter a password every time you ssh in or use SCP to copy files. This tutorial describes the use of SSH key to achieve SSH password-free login, and the use of SCP to copy files will not need to enter the password. In addition to the convenience of SSH login, SCP copy files, ssh password-free login also added a security line for the Linux server.

SSH Password-free login setup Steps
    1. First we generate a pair of SSH key:ssh keys and ssh public keys on our own Linux system. The key is stored on your own Linux system.
    2. The public key is then uploaded to the Linux server. Then we will be able to login without a password ssh. SSH keys are like proof of your identity.
1 generating SSH keys and public keys on your own Linux system

Open the terminal and use the following Ssh-keygen to generate the RSA key and public key. - t represents the type, which means that the key to RSA encryption is generated.

SSH-KEYGEN-T RSA

RSA is also the default encryption type. So you can also just enter Ssh-keygen. The default RSA length is 2048 bits. If you are very safe, you can specify a length of 4,096 bits.

Ssh-keygen-b 4096-t RSA

The process of generating SSH key will require you to specify a file to hold the key, and press ENTER to use the default file. Then you need to enter a password to encrypt your ssh Key. The password must be at least 20 bits in length. The SSH key is saved in the . Ssh/id_rsa file in the home directory. The SSH public key is saved in the . Ssh/id_rsa.pub file.

Generating public/private RSA key pair. enter file in which to save the key (/HOME/MATRIX/.SSH/ID_RSA): Press Enter passphrase (empty for no passphrase) : Enter a password enter same passphrase again: Enter the password again your identification has been saved In/home/matrix/.ssh/id_rsa. Your public key have been saved in/home/matrix/.ssh/id_rsa.pub.the key fingerprint Is:e1:dc:ab:ae:b6:19:b0:19:74:d5:fe : 57:3f:32:b4:d0 [email protected]the key ' s randomart image is:+---[RSA 4096]----+|. || . . || . . .. . || . . o O.. E. | | O S.. O ... | | = .. +...|| O.. O. | | . O. || . ++o |+-----------------+   

Viewing the . Ssh/id_rsa file will see that the file is encrypted (encrypted). That is, use the password you entered to encrypt it.

Less. Ssh/id_rsa

2 Uploading the SSH public key to the Linux server

You can do this by using the ssh-copy-id command.

Ssh-copy-id [email protected]

After you enter the password for the remote user, the SSH public key is automatically uploaded. The SSH public key is stored in the . Ssh/authorized_keys file of the remote Linux server.

Once the upload is complete, SSH login will not need to enter the password again. However, the first time you use SSH key to log in, you need to enter an SSH key encryption password. (You only need to enter it once, you will automatically log in in the future, no longer need to enter the key password.) )

You do not need to enter a password when you use the SCP command to transfer files.

Knowledge of SSH Key

The Linux system has a key ring (keyring) management program. Key ring is protected by user login password. When you log in to the Linux system, the key ring password is automatically unlocked to access the keyring. SSH keys and public keys are also stored in the key ring. So when you first log in to a remote Linux server with an SSH key, you need to enter the password for the SSH key once. In the future, the password is no longer entered using SSH keys. Ubuntu Key Ring Program is seahorse.

SSH keys are like proof of your identity. The remote Linux server encrypts a message with the SSH public key that you generated, and only your SSH key can unlock the message. So if someone doesn't have your ssh key, they can't unlock the encrypted message, and they won't be able to log into your Linux server.

SSH login with no password is as simple as this.

SSH login without password: Only two simple steps (Linux)

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.