Ubuntu ssh password-free login

Source: Internet
Author: User
Tags aliases

1 What is SSH?

  SSH is an encryption protocol, SSH is two encryption password, one is the public key is a private key, public key encryption information only to be able to decrypt. The SSH protocol can be used for communication between services. Example: Login verification, git authorization, etc.

2 SSH Login server (linux,ubuntu)

1) using the Ssh-keygen can generate a secret key SSH encryption algorithm There are two, the following is the way to generate the key:

SSH-KEYGEN-T RSA

Ssh-keygen-t DSA

2) A computer: Use the command to generate a key on a computer, the directory (~/.ssh/) generates two files, one is the public key (Id_rsa.pub), one is the private key (ID_RSA), the public key is for others, the private key is its own

3) b computer: Connect computer B with SSH

SSH [email protected]_host

Prompt to enter a password

5) Create a new file ~/{user}/.ssh/authorized_keys file in computer B and copy the id_rsa.pub of a computer to the file, or you can use the command to operate on a computer:

Cat ~/.ssh/id_rsa.pub | SSH [email protected]_host "Mkdir-p ~/.ssh && cat >> ~/.ssh/authorized_keys"

6) in the B computer to modify the configuration file/etc/ssh/sshd_conf, pubkeyauthentication Yes, rsaauthentication the previous # number to enable SSH public key authentication,

7) Simple SSH configuration is over, and then restart the SSH service sudo services sshd restart,
Use SSH in a computer [email protected]_host can log in directly, do not lose the password.

Sometimes we use SSH, long time does not operate the remote computer The current connection will be broken off, this time also to connect again, this is very inconvenient for developers. This time we're going to change the configuration.

To modify/etc/ssh/sshd_conf on a remote computer:
Clientaliveinterval 60//Requested time interval
Clientalivecountmax 3//number of server requests

The default value of Clientaliveinterval is 0, which means that no request is sent to the client, and setting Clientaliveinterval 60 sends a message to the customer service every minute of the time, ensuring a long connection. Clientalivecountmax 3 Rep

The maximum number of times a server sends a request client without a response, and automatically disconnects if no response is reached. In general, the client is responsive as long as the window is not closed. 

3 SSH alias Login

Sometimes every time you log on to the remote server to enter the user name and host, when the management of multiple units will be very troublesome, this time we need to manage our session, configure aliases. Log on to a different server with a different key on a single computer

By configuring the ~/.ssh/config file, you can easily log in and create one yourself without the file. Configuration information in the following:

Host Alias
HostName Host Name
Port ports
User username
Identityfile path to the local key file (optional default is ~/.ssh/id_rsa.pub)
After the configuration is complete, you can sign in with an alias-free password.
SSH aliases
The above is the learning experience, convenient for later inquiries.

Ubuntu ssh password-free login

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.