1. 生成本机的公私钥匙对
[oracle@Oracle11_2 scripts]$ ssh-keygen -b 1024 -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/oracle/.ssh/id_rsa): (Enter) Created directory '/home/oracle/.ssh'. Enter passphrase (empty for no passphrase): (Enter) Enter same passphrase again: Your identification has been saved in /home/oracle/.ssh/id_rsa. Your public key has been saved in /home/oracle/.ssh/id_rsa.pub. The key fingerprint is: (Enter) ab:a8:93:25:50:f8:32:3f:f5:fd:c3:8b:97:98:7b:e6 oracle@Oracle11_2 The key's randomart image is: (Enter) +--[ RSA 1024]----+ | . | |. . | | o | |+ . . | | = . . .S | | + . . .. | | = .= . | | o . .o.O | | .o. . o*Eo | +-----------------+
2. 将本机的公钥复制到远程机器的authorized_keys文件中,ssh-copy-id也能让你有到远程机器的home, ~./ssh , 和 ~/.ssh/authorized_keys的权利 [oracle@Oracle11_2 scripts]$ ssh-copy-id -i ~/.ssh/id_rsa.pub Oracle11 The authenticity of host 'oracle11 (192.168.199.67)' can't be established. RSA key fingerprint is 54:94:e3:2c:5b:92:f2:a5:03:e0:2c:73:b9:72:dd:d6. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'oracle11,192.168.199.67' (RSA) to the list of known hosts. oracle@oracle11's password: Now try logging into the machine, with "ssh 'Oracle11'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting.
3. 测试 [oracle@Oracle11_2 scripts]$ ssh Oracle11 [oracle@Oracle11 ~]$ exit logout Connection to Oracle11 closed.
参考:http://blog.chinaunix.net/uid-26284395-id-2949145.html
http://blog.sina.com.cn/s/blog_68158ebf0100vf8l.html