- Timestamp:
- Mar 10, 2012, 8:39:58 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/check-batch-cmd
r10093 r10094 56 56 def update_hosts(filters=[]): 57 57 for host in gformat.get_hostlist(): 58 if filters and not any([f in hostfor f in filters]):58 if filters and not any([f.lower() in host.lower() for f in filters]): 59 59 continue 60 60 … … 105 105 106 106 def ubnt_keys(hostname): 107 keys = open( 'authorized_keys','r').read()107 keys = open(os.path.join(gformat.NODE_DIR,'global_keys'),'r').read() 108 108 ssh = paramiko.SSHClient() 109 109 ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 110 110 ssh.connect(hostname, username='root', password=SSHPASS,timeout=3) 111 111 cmd = 'test -d .ssh || mkdir .ssh;\ 112 echo "%s"> .ssh/authorized_keys && \112 cat > .ssh/authorized_keys && \ 113 113 chmod 0700 .ssh && \ 114 chmod 0755 . && cfgmtd -p /etc -w' % keys114 chmod 0755 . && cfgmtd -p /etc -w' 115 115 stdin, stdout, stderr = ssh.exec_command(cmd) 116 stdin.write(keys) 117 stdin.flush() 118 stdin.channel.shutdown_write() 116 119 stdout = stdout.readlines() 117 120 stderr = stderr.readlines() … … 131 134 parser_keys = subparsers.add_parser('keys', help='add ssh keys on UBNT') 132 135 parser_keys.add_argument('host', type=str) 133 parser_ snmp.set_defaults(func='keys')136 parser_keys.set_defaults(func='keys') 134 137 135 138 parser_update = subparsers.add_parser('update', help='process all UBNT')
Note:
See TracChangeset
for help on using the changeset viewer.