[[email protected] ~]# 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
[[email protected] ~]# uname -r
2.6.32-431.23.3.el6.x86_64
[[email protected] ~]# vi /etc/salt/roster slave: host: 192.168.1.130 user: root passwd: passwd# root 密码 port: 22 配置好roster就可以使用salt-ssh 当把key部署好就可以把passwd删除
[[email protected] ~]# 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
调试
[[email protected] ~]# 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:] [[email protected] ~]# salt-ssh ‘slave‘ --key-deploy -r ‘ip a‘ ip ssh.set_auth_key ..................
ip 是方法,当--key-deploy时 方法为ssh.set_auth_key 参数(args)为authorized_keys里面有=
[[email protected] ~]# 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‘
[[email protected] ~]# 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
[[email protected] ~]# salt-ssh ‘slave‘ --key-deploy -r ‘ip -a‘ 运行后到slave(主机名)服务器上查看 [[email protected] .ssh]# pwd /root/.ssh [[email protected] .ssh]# ls authorized_keys [[email protected] .ssh]# cat authorized_keys ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAynKmDMoo1bmXQppDHTULPoZ...KFXmlwzoMQTIla/41IRfGhFYVyBeamEl1rc1U51ak0lVNzbeQ== [email protected]
时间: 2024-10-15 07:29:00