Linux配置ssh自动登录

2011-09-09 15:33:42

技术资料 Linux

生成公钥密钥对-------------
[client@client ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/client/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/client/.ssh/id_rsa.
Your public key has been saved in /home/client/.ssh/id_rsa.pub.
The key fingerprint is:
e7:46:65:43:9d:be:b6:1a:12:dc:31:69:a5:3b:b0:b2 client@client.localdomain
The key´s randomart image is:
+--[ RSA 2048]----+
.............
+-----------------+

将公钥上传至服务端-------------
[client@client ~]$ ssh-copy-id -i ~/.ssh/id_rsa.pub server@server
The authenticity of host ´client (127.0.0.1)´ can´t be established.
RSA key fingerprint is 6a:9c:ab:7b:3c:fd:cc:f9:cb:cb:aa:98:1c:23:ae:c1.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ´client´ (RSA) to the list of known hosts.
server@client´s password:
Now try logging into the machine, with "ssh ´server@server´", and check in:

  .ssh/authorized_keys

to make sure we haven´t added extra keys that you weren´t expecting.

自动登录-------------
[client@client ~]$ ssh server@server
[server@server ~]$ exit