码迷,mamicode.com
首页 > 其他好文 > 详细

salt-ssh 部署key

时间:2014-08-26 11:06:25      阅读:346      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   使用   io   for   ar   2014   

 [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/roster
slave:
  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 a
ip
ssh.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]# ls
authorized_keys 

[root@localhost .ssh]# cat  authorized_keys 
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAynKmDMoo1bmXQppDHTULPoZ...KFXmlwzoMQTIla/41IRfGhFYVyBeamEl1rc1U51ak0lVNzbeQ== root@develop

 

salt-ssh 部署key

标签:style   blog   color   os   使用   io   for   ar   2014   

原文地址:http://www.cnblogs.com/jachin/p/3936560.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!