首页 > 代码库 > salt-ssh 部署key

salt-ssh 部署key

 [root@develop ~]# salt-master --versions-report

Salt: 2014.1.10
Python: 2.7.8 (default, Aug 17 2014, 20:11:11)
Jinja2: 2.7.3
M2Crypto: 0.22
msgpack-python: 0.4.2
msgpack-pure: 0.1.3
pycrypto: 2.6.1
PyYAML: 3.11
PyZMQ: 13.0.0
ZMQ: 3.2.4

[root@develop ~]# uname -r
2.6.32-431.23.3.el6.x86_64

[root@develop ~]# vi /etc/salt/rosterslave:  host: 192.168.1.130  user: root  passwd: passwd# root 密码  port: 22配置好roster就可以使用salt-ssh当把key部署好就可以把passwd删除
[root@develop ~]# salt-ssh ‘slave‘ --key-deploy -r ‘ip a‘...................  File "/usr/local/python27/lib/python2.7/site-packages/salt/client/ssh/__init__.py", line 551, in __arg_comps    (key, val) = arg.split(‘=‘)ValueError: too many values to unpack

 

 

调试

[root@develop ~]# vi /usr/local/python27/lib/python2.7/site-packages/salt/client/ssh/__init__.py    545         fun = comps[0] if comps else      546         import sys  #debug    547         sys.stdout.write("%s\n"%fun)    548         args = comps[1:][root@develop ~]# salt-ssh slave  --key-deploy -r ip aipssh.set_auth_key..................

ip 是方法,当--key-deploy时 方法为ssh.set_auth_key 参数(args)为authorized_keys里面有=

[root@develop ~]# vi /usr/local/python27/lib/python2.7/site-packages/salt/client/ssh/__init__.py           551         for arg in args:    552             if = in arg:    553                 (key, val) = arg.split(=)    554                 kws[key] = val    555             else:    556                 s_args.append(arg)    557         return fun, s_args, kws

key(...==)被切割

key不能走if(552)这个条件,应该直接else

所以在if(552)加上fun!=‘ssh.set_auth_key‘

    [root@develop ~]# vi /usr/local/python27/lib/python2.7/site-packages/salt/client/ssh/__init__.py    540     def __arg_comps(self):    541         ‘‘‘    542         Return the function name and the arg list    543         ‘‘‘    544         comps = self.arg_str.split()    545         fun = comps[0] if comps else ‘‘    546         args = comps[1:]    547         s_args = []    548         kws = {}     549         for arg in args:    550             if = in arg and fun != ssh.set_auth_key:    551                 (key, val) = arg.split(=)    552                 kws[key] = val    553             else:    554                 s_args.append(arg)    555         return fun, s_args, kws
[root@develop ~]# salt-ssh slave  --key-deploy -r ip -a‘ 运行后到slave(主机名)服务器上查看[root@localhost .ssh]# pwd/root/.ssh[root@localhost .ssh]# lsauthorized_keys [root@localhost .ssh]# cat  authorized_keys ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAynKmDMoo1bmXQppDHTULPoZ...KFXmlwzoMQTIla/41IRfGhFYVyBeamEl1rc1U51ak0lVNzbeQ== root@develop

 

salt-ssh 部署key