comparison newkey.py @ 40:f13017bb4502

works on markup with -v ecclerig...
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Mon, 03 Jan 2022 19:19:20 +0000
parents a0b702a76872
children 900ff99ec749
comparison
equal deleted inserted replaced
39:a0b702a76872 40:f13017bb4502
55 55
56 if host!='paul': 56 if host!='paul':
57 if clients[0]!='-': 57 if clients[0]!='-':
58 print("Note, %s will be dereferenced on paul, not locally"%clients, 58 print("Note, %s will be dereferenced on paul, not locally"%clients,
59 file=sys.stderr) 59 file=sys.stderr)
60 cmd="/home/ht/bin/newkey.py %s -i %s %s"%(keytype, 60 cmd="/home/ht/bin/newkey.py %s -i %s"%(keytype,
61 "-v %s"%ihost if ihost is not None else '',
62 '%s'%clients if clients is not None else '') 61 '%s'%clients if clients is not None else '')
63 print(cmd) 62 print(cmd)
64 res=os.system("mkdir -p /tmp/keys ; cd /tmp ; bash -c 'cp -a %s keys' ; tar -czf keys.tar.gz keys"%os.path.expanduser("~/.ssh/id_%s{,.pub}"%keytype)) 63 res=os.system("mkdir -p /tmp/keys ; cd /tmp ; bash -c 'cp -a %s keys' ; tar -czf keys.tar.gz keys"%os.path.expanduser("~/.ssh/id_%s{,.pub}"%keytype))
65 if res: 64 if res:
66 print("tar failed",res) 65 print("tar failed",res)
67 exit(res) 66 exit(res)
68 with open("/tmp/keys.tar.gz","rb") as keytar: 67 with open("/tmp/keys.tar.gz","rb") as keytar:
69 res=run(['ssh','paul',cmd],stdin=keytar).returncode 68 if ihost is None:
70 if res: 69 res=run(['ssh','paul',cmd],stdin=keytar).returncode
71 print("paul failed",res) 70 if res:
72 exit(res) 71 print("paul failed",res)
72 exit(res)
73 else:
74 res=run(['ssh',ihost,'/afs/inf.ed.ac.uk/user/h/ht/share/bin/goHome',cmd],stdin=keytar).returncode
75 if res:
76 print("going via %s failed"%ihost,res)
77 exit(res)
78
73 79
74 if clients[0]=='-': 80 if clients[0]=='-':
75 ssh_copy_id(keyfile,clients[3:]) 81 ssh_copy_id(keyfile,clients[3:])
76 else: 82 else:
77 with open(clients) as cfile: 83 with open(clients) as cfile: