Method 0: Modify the/.ssh/.bash_profile
Increase:
Eval ' ssh-agent '
Ssh-add/root/.ssh/vt_download
Is that the modification takes effect immediately: source. bash_profile
Method 1: Manually use the ssh-agent bash+ssh-add private key path or nohup ssh-add private key path each time
Method 2: Modify the/etc/sshd/ssh.confg file so that the Identityfile private key path takes effect
Method 3: Using the SSH configuration file can greatly facilitate a variety of operations, especially for multiple SSH accounts, use non-standard ports or write scripts, and so on.
Mans Ssh_config
You can view the manual
If you have previously logged in to SSH with a password, you will need to use the certificate method instead. You can look at the last side to generate the SSH certificate configuration file
User profile in ~/.ssh/config, no words to create a new one. The basic wording is
Host name (own decision, convenient input memory)
HostName hostname
User login username
identityfile certificate file path
Two SSH account, one is GitHub, one is the other server, the certificate file as its name, then can write
Host github.com
HostName github.com
User git
identityfile ~/.ssh/github
host Server
HostName Server address User
login username
identityfile ~/.ssh/server
Note that the GitHub host must be written as "github.com". You can have other requirements, such as specifying the port number and binding the ports, which can be queried by man, such as
Port port number
Dynamicforward Local port number
If the server has Ipv4/ipv6 address at the same time, hostname use domain name will be more convenient to use
With these configurations, many operations are simplified. Like logging on to a server
SSH server
Transfer files
If you use tools such as putty, you may need some other action (convert the private key format, seemingly), search it yourself generate SSH certificate
Log on to the server, generate the key (you use which username to log in, in which user name generated)
SSH-KEYGEN-T RSA
Ask where to put the key, by default. Then enter the password and leave it blank (otherwise you will not only need the private key but also enter the password for login).
When completed, another file is generated in the ~/.ssh directory Id_rsa, Id_rsa.pub, and a private key a public key. Then execute
CD ~/.ssh
cat id_rsa.pub >> authorized_keys
chmod authorized_keys
Id_rsa back the local, put the ~/.SSH and set the permissions to 400.
Server side, delete the two files and modify the sshd configuration. Edit/etc/ssh/sshd_config as follows
Pubkeyauthentication Yes
passwordauthentication No
Restart the sshd service later