Changeset 10094 in genesis


Ignore:
Timestamp:
Mar 10, 2012, 8:39:58 PM (13 years ago)
Author:
rick
Message:

Echo does not work, cat with closing stdin works fine.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/check-batch-cmd

    r10093 r10094  
    5656def update_hosts(filters=[]):
    5757  for host in gformat.get_hostlist():
    58     if filters and not any([f in host for f in filters]):
     58    if filters and not any([f.lower() in host.lower() for f in filters]):
    5959      continue
    6060
     
    105105
    106106def ubnt_keys(hostname):
    107   keys = open('authorized_keys','r').read()
     107  keys = open(os.path.join(gformat.NODE_DIR,'global_keys'),'r').read()
    108108  ssh = paramiko.SSHClient()
    109109  ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    110110  ssh.connect(hostname, username='root', password=SSHPASS,timeout=3)
    111111  cmd = 'test -d .ssh || mkdir .ssh;\
    112     echo "%s" > .ssh/authorized_keys && \
     112    cat > .ssh/authorized_keys && \
    113113    chmod 0700 .ssh && \
    114     chmod 0755 . && cfgmtd -p /etc -w' % keys
     114    chmod 0755 . && cfgmtd -p /etc -w'
    115115  stdin, stdout, stderr = ssh.exec_command(cmd)
     116  stdin.write(keys)
     117  stdin.flush()
     118  stdin.channel.shutdown_write()
    116119  stdout = stdout.readlines()
    117120  stderr = stderr.readlines()
     
    131134  parser_keys = subparsers.add_parser('keys', help='add ssh keys on UBNT')
    132135  parser_keys.add_argument('host', type=str)
    133   parser_snmp.set_defaults(func='keys')
     136  parser_keys.set_defaults(func='keys')
    134137
    135138  parser_update = subparsers.add_parser('update', help='process all UBNT')
Note: See TracChangeset for help on using the changeset viewer.