生成公私钥
##########生成公私钥#######################
[root@localhost ~]# ssh-keygen -t rsa
###########生成公私钥######################
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 回车
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 回车
Enter same passphrase again: 回车
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
f0:42:dc:45:9f:1d:61:43:4e:77:fe:81:90:a0:cb:b2 root@localhost.localdomain
The key's randomart image is:
+--[ RSA 2048]----+
| o+...B.o|
| . ... o.*.=.|
| +.. o.o..|
| ..o. o|
| ..oS .|
| o. |
| E |
| |
| |
+-----------------+
[root@localhost ~]# cd .ssh/
[root@localhost .ssh]# ll
总用量 8
-rw------- 1 root root 1679 11月 30 16:59 id_rsa
-rw-r--r-- 1 root root 408 11月 30 16:59 id_rsa.pub
##########将公钥写入authorized_keys文件##########
[root@localhost .ssh]#cat id_rsa.pub >> authorized_keys
[root@localhost .ssh]#chmod 600 authorized_keys
##########将公钥写入authorized_keys文件##########
[root@localhost .ssh]# ll
总用量 12
-rw-r--r-- 1 root root 408 11月 30 17:04 authorized_keys
-rw------- 1 root root 1679 11月 30 16:59 id_rsa
-rw-r--r-- 1 root root 408 11月 30 16:59 id_rsa.pub
jenkins配置私钥凭证
jenkins设置ssh私钥连接
SSH remote hosts连接配置
Publish over SSH连接配置
1、修改服务器的root密码,不影响公私钥使用,这两种方式是独立;