作用:通过SSH模块管理客户端的ssh远程服务,并用key认证方式替代密码认证方式,提高安全性;本例分两阶段,首先是ssh的安装、配置及服务管理,然后是使用如何转换成key认证方式#第一阶段1、服务端配置ssh模块。
(1)模块清单123456789101112[root@puppet ~]# tree /etc/puppet/modules/ssh//etc/puppet/modules/yum/├── files
│ └── sshd_config├── manifests│ ├── config.pp│ ├── init.pp│ ├── install.pp│ ├── params.pp│ ├── key.pp
│ └── service.pp└── templates(2)定义参数类123456789101112131415161718[root@puppet ~]# vi /etc/puppet/modules/ssh/manifests/params.pp
class ssh::params { case $operatingsystem { #条件判断,根据操作系统来定义同名参数不同的值 Solaris: { $ssh_package_name = openssh
$ssh_service_config = /etc/ssh/sshd_config $ssh_service_name = sshd } /(RedHat|CentOS|Fedora|Ubuntu|Debian)/: {
$ssh_package_name = openssh-server $ssh_service_config = /etc/ssh/sshd_config $ssh_service_name = sshd
} default: { fail(“Module ssh is not supported on ${::operatingsystem}”) } }}(3)定义安装类
123456[root@puppet ~]# vi /etc/puppet/modules/ssh/manifests/install.ppclass ssh::install { package { ssh::params::ssh_package_name:
ensure => installed, }}(4)定义配置类123456789101112[root@puppet ~]# vi /etc/puppet/modules/ssh/manifests/config.pp
class ssh::config { file { ssh::params::ssh_service_config: ensure => present, owner => root,
group => root, mode => 0600, source => “puppet:///modules/ssh/sshd_config”, require => Class[“ssh::install”],
notify => Class[“ssh::service”], }}(5)定义服务类12345678910[root@puppet ~]# vi /etc/puppet/modules/ssh/manifests/service.pp
class ssh::service { service { ssh::params::ssh_service_name: ensure => running, hasstatus => true,
hasrestart => true, enable => true, require => Class[“ssh::config”], }}(7)定义ssh主类12
345[root@puppet ~]# vi /etc/puppet/modules/ssh/manifests/init.ppclass ssh { include ssh::params include ssh::install,ssh::config,ssh::service
}(8)定义节点文件,调用模块1234[root@puppet ~]# vi /etc/puppet/manifests/centostest.ppnode “centostest.ewin.com” {
include ntp, yum, puppet, host, ssh}(9)应用节点文件12[root@puppet ~]# vi /etc/puppet/manifests/site.ppimport “centostest.pp”
(10)复制配置文件复制一份SSH的配置文件(/etc/ssh/sshd_config)到puppet的目录下(/etc/puppet/modules/ssh/files/sshd_config),并在文件顶部插入一条注释说明:
1### config by puppet ###2、测试第一阶段(1)客户端运行puppet agent -t,同时观察日志1234[root@centostest ~]# tailf /var/log/messages
Nov 12 10:56:08 centostest puppet-agent[39921]: (/Stage[main]/Ssh::Config/File[/etc/ssh/sshd_config]/content) content changed {md5}53ad75eb1f2269d23f6e4228353cbca3 to {md5}a271889f546ff10b7af311ba35ed5e1c
Nov 12 10:56:09 centostest puppet-agent[39921]: (/Stage[main]/Ssh::Service/Service[sshd]) Triggered refresh from 1 events
Nov 12 10:56:09 centostest puppet-agent[39921]: Finished catalog run in 2.59 seconds结论:配置文件更新,服务类刷新了一次,ssh的基本管理配置成功
(2)服务端通过ssh远程客户端12345678[root@puppet ~]# ls /root/.ssh/ #查看密钥目录[root@puppet ~]# ssh centostest.ewin.com #Ssh远程连接,可以用IP地址
The authenticity of host centostest.ewin.com (10.188.1.85) can t be established.RSA key fingerprint is 0d:79:7b:52:6c:8a:0c:cf:95:8e:f7:25:b4:95:98:c8.
Are you sure you want to continue connecting (yes/no)? yes #输入yes确认连接Warning: Permanently added centostest.ewin.com,10.188.1.85 (RSA) to the list of known hosts. #添加到known_hosts列表中
root@centostest.ewin.com s password: #输入客户端centostest的root用户的密码Last login: Wed Nov 12 10:52:34 2014 from ywzhou-pc.ewin.com #记录的最后一次登陆记录
结论:第一次通过ssh连接客户端会创建主机密钥并记录到known_hosts,提示输入root密码,这便是最常用的密码认证方式12345678[root@centostest ~]# exit #退出ssh连接,返回到puppet服务器。
logoutConnection to centostest.ewin.com closed.[root@puppet ~]# ls /root/.ssh/ #再次查看密钥目录,出现了生成的记录文件
known_hosts[root@puppet ~]# ssh centostest.ewin.com #重新远程连接客户端,不再确认密钥root@centostest.ewin.coms password:
Last login: Wed Nov 12 11:06:36 2014 from puppet.ewin.com结论:第二次连接会读取known_hosts中记录的主机密钥,只需输入root密码后即可连接
#第二阶段说明:sshkey认证方式可以在linux服务器上(如puppet服务器)生成密钥,通过puppet服务器ssh到客户端进行管理;也可以在windows机器上使用连接管理工具(如Xshell 4或SecureCRT)生成密钥,这也是运维人员常用的软件;sshkey认证方式可以安全的、无需密码的、快速的连接客户端进行管理;
先介绍如何在puppet服务器上生成无密码的密钥(私钥和公钥一对),将公钥分发到客户端,关闭ssh的password认证连接3、使用ssh-keygen命令生成认证密钥(1)服务端生成密钥1234567
89[root@puppet ~]# ssh-keygen -t dsaGenerating public/private dsa key pair.Enter file in which to save the key (/root/.ssh/id_dsa): #私钥保存路径
Enter passphrase (empty for no passphrase): #输入一个密语字符串,这里可以直接回车,空密码Enter same passphrase again:Your identification has been saved in /root/.ssh/id_dsa. #私钥
Your public key has been saved in /root/.ssh/id_dsa.pub. #公钥The key fingerprint is:af:eb:5a:45:a7:91:dc:80:6e:03:75:ec:71:ae:2d:a0 root@centostest.ewin.com
参数说明:-t表示密钥类型,dsa或rsa,都是SSH2的,不支持SSH1;后面还可接-C “puppet test sshkey”表示注释,用来标示密钥的用途(3)查看生成的密钥12[root@puppet ~]# ls /root/.ssh/。
id_dsa id_dsa.pub known_hosts说明:三个文件分别是私钥、共钥、已连接过的SSH客户端密钥记录,下面来查看密钥文件:123456789101112131415[root@centostest ~]# cat /root/.ssh/id_dsa
—–BEGIN DSA PRIVATE KEY—–Proc-Type: 4,ENCRYPTEDDEK-Info: DES-EDE3-CBC,AB0A77C490AD5CE6LCpOrQ8tKnAzDW1efWEB5AB2BXbnGUJLxKNpiwqyxR96XGVQEjgzqQwcjB6GJLI5
HUCW8JpS5IqdegJgsY76QRE4PD9XRiZRWEhaP+9v0NMFGF6lU93ahrk5DR3JmpgxjhJEPZTCSB889SaGhz+E89BOrxjRDootyiyYOjlwekvHQPJ0nrMt27shMYJ4apym
tXahjdlwlbzJzrONhq9eMklmZnfy/l8VdiDnVcUUIQMLN5IPZBcJiqFGUbLMspI3E5zBI7jGcF/QYeOv7IeK8cjaZ8AwBznZOnOB9HUEBuwDAFS/Q6urAaeri2XvVgBy
1AcGljNZCfM4ltogNGzrZeVydtcqQstEPjCr8bpWkN4eq+PvXw3eA/5WkDaLpX88qt8EkZ3HMa1zu2pRZ5iCG4z2rTxO9vFUXJnU+Un720jGYTEihWDycEiOco0brCgt
eQt8fwnbNO/GmQCeX5UeoGo92zqYMKUosHx65Kx+kmaxfAmaL7GPszCM3D9NgqY9L6+eEyVyLaNecmD+ishPAFsyqA0pfIJClsNNQXYHL1Mbm5ADCAjfiguJjQZBzQt1
l8zSc6dCxaKgZoQ+epmjGjN5jbyXcqER—–END DSA PRIVATE KEY—–12[root@centostest ~]# cat /root/.ssh/id_dsa.pub
ssh-dss AAAAB3NzaC1kc3MAAACBAJrukh4ukPZ75uQEtLdczpv9RrjJDAY15wtJtVBtl1bUNxOdUiE3hlcqBRMrU01bokdz6LZQgy7j24k11/dS5ojawzkC9J5a4q4tBu3geasmmg+sd1GcC/mAYumCg2YzVGlsrUwbzgU62m7+FZSej0ySGORoaGcHLxdrpy24A5qbAAAAFQDt4RpHlMCV2bv2/kLcCZdI416S3QAAAIEAl2P8cZgSYRbO2pGMTp4wP7jfq/1EXq/+kNa4SpEpUT/qQbfLUSNSEcKMsQKGSiDih4AzTfTPxHf4UGwfB/Cxv9WdYEALrImE3KvETsY561u7UcgBLQkqLJsJLHp/q4qCLkgLfiohzn2aQKivtgqUCrQ9wAZUhW9FUZwskVWM884AAACAclP+RlLbblUL5eTzq4DEpOtWKbX5UXXwxoOyrc5ADS6NtM9D3jyB/pJ/Oiz4uU33J810EmYJLkPTph0FKk94MiCkQLg6zaoV9Ljlbw2BS46YzdEv5bCKjqaW9jIh+o/PnfF8kGRyIImGLce6SasGhRqkm6E3z2djBMtA/u9TZok= root@centostest.ewin.com
说明:将公钥文件id_dsa.pub中的三段(类型、密钥编码、用户)定义到密钥类中(4)定义密钥类1234567891011[root@puppet ~]# vi /etc/puppet/modules/ssh/manifests/key.pp
class ssh::key { ssh_authorized_key { “puppet”: #管理机的主机名,也是公钥名,不重复就行 ensure => present, #基础属性,指定key是否生成,present、absent
type => “ssh-dss”, #key的加密类型 key => “AAAAB3NzaC1kc3MAAACBAJrukh4ukPZ75uQEtLdczpv9RrjJDAY15wtJtVBtl1bUNxOdUiE3hlcqBRMrU01bokdz6LZQgy7j24k11/dS5ojawzkC9J5a4q4tBu3geasmmg+sd1GcC/mAYumCg2YzVGlsrUwbzgU62m7+FZSej0ySGORoaGcHLxdrpy24A5qbAAAAFQDt4RpHlMCV2bv2/kLcCZdI416S3QAAAIEAl2P8cZgSYRbO2pGMTp4wP7jfq/1EXq/+kNa4SpEpUT/qQbfLUSNSEcKMsQKGSiDih4AzTfTPxHf4UGwfB/Cxv9WdYEALrImE3KvETsY561u7UcgBLQkqLJsJLHp/q4qCLkgLfiohzn2aQKivtgqUCrQ9wAZUhW9FUZwskVWM884AAACAclP+RlLbblUL5eTzq4DEpOtWKbX5UXXwxoOyrc5ADS6NtM9D3jyB/pJ/Oiz4uU33J810EmYJLkPTph0FKk94MiCkQLg6zaoV9Ljlbw2BS46YzdEv5bCKjqaW9jIh+o/PnfF8kGRyIImGLce6SasGhRqkm6E3z2djBMtA/u9TZok=”, #生成的密钥值,一般是十六进制数字的长字符串
target => “/root/.ssh/authorized_keys”, #存储的SSH密钥文件的路径 user => root, #指定是哪个用户(客户端)的key
require => Class[“ssh::install”], }}说明:可以使用puppet的user资源定义一个用户来分配sshkey,常用于多级系统管理员的IT部门(5)定义ssh主类。
12345[root@puppet ~]# vi /etc/puppet/modules/ssh/manifests/init.ppclass ssh { include ssh::params include ssh::install, ssh::config, ssh::service, ssh::key
}(6)定义节点文件,调用模块1234[root@puppet ~]# vi /etc/puppet/manifests/centostest.ppnode “centostest.ewin.com” {
include ntp, yum, puppet, host, ssh}(7)应用节点文件12[root@puppet ~]# vi /etc/puppet/manifests/site.ppimport “centostest.pp”
(8)修改ssh配置文件12[root@puppet ~]# vi /etc/puppet/modules/ssh/files/sshd_configPasswordAuthentication no #关闭密码认证
4、测试第二阶段(1)客户端运行puppet agent -t,同时观察日志1234[root@centostest ~]# tailf /var/log/messagesNov 12 11:39:39 centostest puppet-agent[28301]: (/Stage[main]/Ssh::Config/File[/etc/ssh/sshd_config]/content) content changed {md5}a271889f546ff10b7af311ba35ed5e1c to {md5}1983ed7e2956b9bd4c627e45906b193e
Nov 12 11:39:39 centostest puppet-agent[28301]: (/Stage[main]/Ssh::Service/Service[sshd]) Triggered refresh from 1 events
Nov 12 11:39:49 centostest puppet-agent[28534]: (/Stage[main]/Ssh::Key/Ssh_authorized_key[puppet]/ensure) created
结论:更新了配置文件、重启了服务、创建了密钥记录文件(2)服务端通过ssh远程客户端123[root@puppet ~]# ssh centostest.ewin.comLast login: Wed Nov 12 11:08:49 2014 from puppet.ewin.com
[root@centostest ~]#结论:使用密钥认证方式连接,无需输入密码直接就连接上了(3)查看客户端生成的密钥文件1234567891011121314[root@centostest ~]# cat /root/.ssh/authorized_keys
# HEADER: This file was autogenerated at Tue Nov 12 11:39:49 +0800 2014# HEADER: by puppet. While it can still be managed manually, it
# HEADER: is definitely not recommended.ssh-dss AAAAB3NzaC1kc3MAAACBAJrukh4ukPZ75uQEtLdczpv9RrjJDAY15wtJt
VBtl1bUNxOdUiE3hlcqBRMrU01bokdz6LZQgy7j24k11/dS5ojawzkC9J5a4q4tBu3geasmmg+sd1GcC/mAYumCg2YzVGlsrUwbzgU62m7+FZSej0ySGORoaGcHLxdrpy2
4A5qbAAAAFQDt4RpHlMCV2bv2/kLcCZdI416S3QAAAIEAl2P8cZgSYRbO2pGMTp4wP7jfq/1EXq/+kNa4SpEpUT/qQbfLUSNSEcKMsQKGSiDih4AzTfTPxHf4UGwfB/Cxv
9WdYEALrImE3KvETsY561u7UcgBLQkqLJsJLHp/q4qCLkgLfiohzn2aQKivtgqUCrQ9wAZUhW9FUZwskVWM884AAACAclP+RlLbblUL5eTzq4DEpOtWKbX5UXXwxoOyrc5
ADS6NtM9D3jyB/pJ/Oiz4uU33J810EmYJLkPTph0FKk94MiCkQLg6zaoV9Ljlbw2BS46YzdEv5bCKjqaW9jIh+o/PnfF8kGRyIImGLce6SasGhRqkm6E3z2djBMtA/u9TZ
ok= puppet结论:可以看到客户端的认证密钥文件中成功记录了前面生成的公钥;通过头部注释信息可以看到是由puppet部署的另外如果不是指定root用户,就在/home//.ssh中查找。
注意:authorized_keys中只会保存由puppet的ssh_authorized_key部署的公钥,其他的自动删除(4)其他服务端访问测试123456[root@zabbix ~]# ssh 10.188.1.85。
The authenticity of host 10.188.1.85 (10.188.1.85) cant be established.RSA key fingerprint is 0d:79:7b:52:6c:8a:0c:cf:95:8e:f7:25:b4:95:98:c8.
Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 10.188.1.85 (RSA) to the list of known hosts.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).结论:可以看到Permission denied权限拒绝,无法登陆,密码认证方式被关闭了,成功转换到KEY认证。
#扩展阶段说明:添加一台管理机公钥,在windows系统下使用工具进行sshkey认证连接。5、生成认证密钥(1)使用Xshell创建用户密钥
说明:密码可以为空
(2)使用SecureCRT创建用户密钥
说明:进入KEY的目录,用记事本打开Identity.pub查看公钥信息(3)将公钥注册页面上的信息添加到密钥类文件中123456789101112131415161718192021[root@puppet ~]# vi /etc/puppet/modules/ssh/manifests/key.pp
class ssh::key { ssh_authorized_key { “puppet”: ensure => present, type => “ssh-dss”, key => “AAAAB3NzaC1kc3MAAACBAMzwtzbkG9yV8C9zM3n85FzJJaZrEPJbDQ1ZFfhkpZm2VYPHaFxCI3M2jTvHtkBV2OKlkHg2mrZ2Xt6Tp+d3E5ophZMdZmuOApiQPhD5z0Ld0/Wb2RJzLTwYy/BO+UNPnlorpy0kJjvjCrAACcIIVtbUMquKcdydfL8KV+shPEm3AAAAFQCRQw1nUvCqvL8tvOM+8cc6A2/tcQAAAIAWpKoqsoHIQp6bFeY7+tNQFo11Yzl3T3UJq7HG7CkOWQdMKwJJBXvub3Sgp9hA4415A12G8GKfxRn6JotmLLiAXeQmYYGLR9wwGTqYNNZwJL2JhtHe4HroGp7CuP5M71NcZ5QtvwIMqxa30kYOKf4RaV5mpf/K13VItrjcK5hxAwAAAIEAxodCPc3l63iBkjDhAUzfZyU3KtgIa/AO6E6t/60j485w0aYl2fpam+oA2akvtgZSMIZ1o9dkQotMCubz82wsMo6nDia8V89D3goEn0Uu1512dxpPWXN7cH8C4BC0Vu1QXHYY8ASkSAPMsSTsD49Ir736BIFSk2oTOcIKIJYpNO0=”,
target => “/root/.ssh/authorized_keys”, user => root, require => Class[“ssh::install”], }
#添加ywzhou-pc的公钥资源 ssh_authorized_key { “ywzhou-pc”: ensure => present, type => “ssh-dss”, key => “AAAAB3NzaC1kc3MAAACBAPrbA22nnuySLeoddXjkehPkX3qUjRt8vbJPgGoWzRW8gAN88+xU7806/nqKso5pNAxP6XsDDkG/MYhtvXXgTlOxpeAkXZQpVUtHZp/ycnTRlqCzmDZ5uHqrChcVKEP/jT9qLcxdEkyBClHefBIKiN4SeeB6hF+X4+3ZGecb8ljvAAAAFQCrbJQ0w24MRAFUeV3LLNRn3S4z3wAAAIAzehQUM1wtbXHhgG4PuvkCVQJEqJNFgefHlL10Tjeb8qVCVlfV7eULbmlwVnMReUBwc3tq4e15Bfpa5SoBtRpK3Srb0z/0Nyicfp1ADl+JW4VR0TxcsFKBLSvCwma2ch9wKg5I1AwXlRTV+ayD4RyXmLhg1Mf8i2bZblNaazdRhAAAAIEAsFQbDzmYkd8rGRjj2MJ2bQP2vutVzCMmRp8iDEbRPSiNX0hXhPioet/uyXaqjBjY6n26HsIGOUl2W8CYGpjuFtZ9qw0m7gNKghFOSjqRdOYQAG9/BG9kysIH6UFMarHxSXd9CGs2eRh4o3lXgA7LvSMzHDSRHY5dyxlYCBXPDw8=”,
target => “/root/.ssh/authorized_keys”, user => root, require => Class[“ssh::install”], }
}6、测试扩展阶段(1)客户端运行puppet agent -t,同时查看日志12[root@centostest ~]# tailf /var/log/messagesNov 12 12:17:30 centostest puppet-agent[10082]: (/Stage[main]/Ssh::Key/Ssh_authorized_key[ywzhou-pc]/ensure) created
(2)客户端查看公钥记录文件12345678910111213141516171819202122[root@centostest ~]# cat /root/.ssh/authorized_keys# HEADER: This file was autogenerated at Wed Nov 12 12:17:30 +0800 2014
# HEADER: by puppet. While it can still be managed manually, it# HEADER: is definitely not recommended.
ssh-dss AAAAB3NzaC1kc3MAAACBAPrbA22nnuySLeoddXjkehPkX3qUjRt8vbJPgGoWzRW8gAN88+xU7806/nqKso5pNAxP6XsDDkG/MYhtvXXgTlOxpeAkXZQpVUtHZp/ycnTRlq
CzmDZ5uHqrChcVKEP/jT9qLcxdEkyBClHefBIKiN4SeeB6hF+X4+3ZGecb8ljvAAAAFQCrbJQ0w24MRAFUeV3LLNRn3S4z3wAAAIAzehQUM1wtbXHhgG4PuvkCVQJEqJNFgefHlL10
Tjeb8qVCVlfV7eULbmlwVnMReUBwc3tq4e15Bfpa5SoBtRpK3Srb0z/0Nyicfp1ADl+JW4VR0TxcsFKBLSvCwma2ch9wKg5I1AwXlRTV+ayD4RyXmLhg1Mf8i2bZblNaazdRhAAAAI
EAsFQbDzmYkd8rGRjj2MJ2bQP2vutVzCMmRp8iDEbRPSiNX0hXhPioet/uyXaqjBjY6n26HsIGOUl2W8CYGpjuFtZ9qw0m7gNKghFOSjqRdOYQAG9/BG9kysIH6UFMarHxSXd9CGs
2eRh4o3lXgA7LvSMzHDSRHY5dyxlYCBXPDw8= ywzhou-pcssh-dss AAAAB3NzaC1kc3MAAACBAMzwtzbkG9yV8C9zM3n85FzJJaZrEPJbDQ1ZFfhkp
Zm2VYPHaFxCI3M2jTvHtkBV2OKlkHg2mrZ2Xt6Tp+d3E5ophZMdZmuOApiQPhD5z0Ld0/Wb2RJzLTwYy/BO+UNPnlorpy0kJjvjCrAACcIIVtbUMquKcdydfL8KV+shPEm3AAAAFQC
RQw1nUvCqvL8tvOM+8cc6A2/tcQAAAIAWpKoqsoHIQp6bFeY7+tNQFo11Yzl3T3UJq7HG7CkOWQdMKwJJBXvub3Sgp9hA4415A12G8GKfxRn6JotmLLiAXeQmYYGLR9wwGTqYNNZwJ
L2JhtHe4HroGp7CuP5M71NcZ5QtvwIMqxa30kYOKf4RaV5mpf/K13VItrjcK5hxAwAAAIEAxodCPc3l63iBkjDhAUzfZyU3KtgIa/AO6E6t/60j485w0aYl2fpam+oA2akvtgZSMIZ
1o9dkQotMCubz82wsMo6nDia8V89D3goEn0Uu1512dxpPWXN7cH8C4BC0Vu1QXHYY8ASkSAPMsSTsD49Ir736BIFSk2oTOcIKIJYpNO0= puppet
(3)window管理机使用Xshell工具连接客户端
说明:因为设置的是空密码,直接回车即可连接。(4)window管理机使用SecureCRT工具连接客户端
说明:因为没有在puppet中定义SecureCRT的公钥,因此认证失败,如何添加自己尝试7、ssh资源(sshkey和ssh_authorized_key)(1)sshkey资源说明:sshkey资源负责如何安装key到/etc/ssh/ssh_known_hosts,不能管理用户的授权密钥,因此不常用。
123456789sshkey { resource title: name => #密钥相关的主机名 ensure => #基本属性,present, absent host_aliases => #主机别名,支持数组表示多个别名
key => #密钥,通常是一长串编码字符窜 target => #存储SSH密钥的文件 type => #SSH类型,ssh-dss (dsa), ssh-ed25519 (ed25519), ssh-rsa (rsa),
#ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521}(2)ssh_authorized_key资源
说明:ssh_authorized_key资源负责管理授权密钥,大部分都使用这个资源类型123456789ssh_authorized_key { resource title: name => “hostname”, #主机名
ensure => present, #基础属性,指定key是否生成,present、absent type => “ssh-dss”, #key生成的加密类型,ssh-dsa或ssh-rsa
key => “密钥值”, #生成的密钥值,一般是十六进制数字的长字符串 target => “/home/sky/.ssh/authorized_keys”, #存储的SSH密钥文件的路径
user => sky, #指定是哪个用户的key options => , #其他选项}(3)官方例子#查看密钥字符串12cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAy5mtOAMHwA2ZAIfW6Ap70r+I4EclYHEec5xIN59ROUjss23Skb1OtjzYpVPaPH8mSdSmsN0JHaBLiRcu7stl4O8D8zA4mz/vw32yyQ/Kqaxw8l0K76k6t2hKOGqLTY4aFbFISV6GDh7MYLn8KU7cGp96J+caO5R5TqtsStytsUhSyqH+iIDh4e4+BrwTc6V4Y0hgFxaZV5d18mLA4EPYKeG5+zyBCVu+jueYwFqM55E0tHbfiaIN9IzdLV+7NEEfdLkp6w2baLKPqWUBmuvPF1Mn3FwaFLjVsMT3GQeMue6b3FtUdTDeyAYoTxrsRo/WnDkS6Pa3YhrFwjtUqXfdaQ== nick@magpie.puppetlabs.lan
#翻译成SSH密钥资源12345ssh_authorized_key { nick@magpie.puppetlabs.lan: user => nick, type => ssh-rsa, key => AAAAB3NzaC1yc2EAAAABIwAAAQEAy5mtOAMHwA2ZAIfW6Ap70r+I4EclYHEec5xIN59ROUjss23Skb1OtjzYpVPaPH8mSdSmsN0JHaBLiRcu7stl4O8D8zA4mz/vw32yyQ/Kqaxw8l0K76k6t2hKOGqLTY4aFbFISV6GDh7MYLn8KU7cGp96J+caO5R5TqtsStytsUhSyqH+iIDh4e4+BrwTc6V4Y0hgFxaZV5d18mLA4EPYKeG5+zyBCVu+jueYwFqM55E0tHbfiaIN9IzdLV+7NEEfdLkp6w2baLKPqWUBmuvPF1Mn3FwaFLjVsMT3GQeMue6b3FtUdTDeyAYoTxrsRo/WnDkS6Pa3YhrFwjtUqXfdaQ==,
}#应用SSH资源到USER资源中1234user { nick: ensure => present, purge_ssh_keys => true,}#将会删除~/.ssh/authorized_keys中不被ssh_authorized_key管理的密钥