[jenkins@ RBS-09 ~]$ ssh-keygen -t rsa
#可以使用-t选项选择加密方式,包括 RSA 和 DSA 两种密钥#例如:$ssh-keygen -t dsa 或者ssh-keygen -t rsa#加密方式不同,key的名称不同,其他没有区别#如果没有指定密钥,默认RSAGenerating public/private rsa key pair.
#私钥存放的位置,默认会存放在用户目录的.ssh文件夹,直接回车Enter file in which to save the key (/home/froad/.ssh/id_rsa):Enter passphrase (empty for no passphrase):#默认,回车Enter same passphrase again:#默认,回车Your identification has been saved in /home/jenkins/.ssh/id_rsa.#私钥路径Your public key has been saved in /home/jenkins/.ssh/id_rsa.pub.#公钥路径The key fingerprint is:6b:81:28:af:5e:54:bb:af:cf:e3:f5:2d:0a:aa:50:71 jenkins@ RBS-09.funshion.com
[jenkins@ RBS-09 ~]$
[jenkins@ RBS-09 .ssh]$ ssh root@192.168.2.xxx
#root是用户名,可以根据你的需求改变
The authenticity of host '192.168.2.xxx (192.168.2.xxx)' can't be established.
RSA key fingerprint is ff:07:49:4d:xxxxxxxxxxe:2c:38.
Are you sure you want tocontinue connecting (yes/no)? yes
#同意将指纹添加到本地
Warning: Permanently added '192.168.2.xxx' (RSA) tothelistof known hosts.
Last login: Wed Oct 2313:58:322013from192.168.1.xxx
[05/15/1409:37:32] [SSH] Opening SSH connection to 10.10.22.37:22.ERROR: Server rejected the 1 private key(s) for jenkins (credentialId:7265ff8a-1515-4745-a174-e6f550630818/method:publickey)
[05/15/1409:37:32] [SSH] Authentication failed.
hudson.AbortException: Authentication failed.
at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:1143)
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:648)
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:642)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:701)
[05/15/1409:37:32] [SSH] Connection closed.
[05/15/1409:37:32] Launch failed - cleaning up connection