Remote login/passwordless login of Linux commands - ssh, ssh-keygen, ssh-copy-id

http://blog.csdn.net/wangjunjun2008/article/details/20037101

In a trusted environment, if you have to enter a password every time you log in remotely, it feels like a waste of time, especially if the password is very complex and the maintenance of the server is relatively in many cases.
So there is a normal requirement: remote login can be achieved without entering a password.
The implementation steps are as follows:
1. Generate a pair of key files (public key and private key) locally;
$ ssh-keygen #The
above command is equivalent to ssh-keygen -t rsa
#-t: Specify the type of key, the default is SSH -2 rsa type;
after running the above command, a series of prompts will appear in the system, and you can press Enter all the way. In particular, one of the questions is whether to set a passphrase for the private key. If you are concerned about the security of the private key, you can set one. After running, two new files will be generated in the ~/.ssh/ directory: id_rsa.pub and id_rsa. The former is the public key and the latter is the private key.

2. Transfer the public key to the remote host host;
$ ssh-copy-id user@host
After the above two steps, passwordless remote login can be realized (the remote host saves the user's public key in ~/.ssh/ authorized_keys file).

3. Remotely connect to the server:
ssh [email protected]

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326992471&siteId=291194637