Basic use of SSH for Linux.
Often log on to a server, do not want to enter the user name and password every time, how to do?
1. Public and private key law, password-free login.
In fact, secret key public key method, than with the user name and password to be more secure, basically can not brute force, of course, if the private key is stolen play.
Generate a pair of public and secret keys on the Linux machine on your own side first.
SSH-KEYGEN-T RSA
3 consecutive returns will generate a pair of keys in the user's. SSH directory Id_rsa and Id_rsa.pub,id_rsa.pub is of course the public key.
The following is to get the public key that was just generated to the server to log on.
Where should this file be located on the server, go to the user directory, and use Ls-al to see a. SSH directory, if not just one time on the server SSH will be generated, into. SSH, do a file called Authorized_keys, Copy the file contents of the public key to this file, and of course there is a handy command to complete. Executed on the client side of the machine
Ssh-copy-id-i ~/.ssh/id_rsa.pub [email protected] Server IP
Here root is to be transferred to the server user, this automatic login is for the user, the general default is to use this user name.
For example, if the client is logged in with Root,
SSH server IP
So is the login server root account, if you want to login to other accounts before the IP address plus user name @, [email protected]
In addition, depending on the version of the machine, this key login is not necessarily possible.
Need to edit pubkeyauthentication Yes in/etc/ssh/sshd_config file
2. Port forwarding
This article from "Genius without that 1% is absolutely impossible" blog, please be sure to keep this source http://xushen.blog.51cto.com/1673219/1672506
The SSH usage of CentOS