equal
deleted
inserted
replaced
|
1 #!/usr/bin/python |
|
2 |
|
3 import os |
|
4 import os.path |
|
5 |
|
6 # THIS SCRIPT COMPLETELY DESTROYS YOUR .ssh/authorized_keys FILE EVERY TIME IT IS RUN |
|
7 |
|
8 #command='cd %s && ../path/bin/hg-ssh %s' % (repos, " ".join(projects)) |
|
9 |
|
10 akeyfile = os.path.expanduser("~/.ssh/authorized_keys") |
|
11 |
|
12 akeys = open(akeyfile + "_new", "w") |
|
13 for root, dirs, files in os.walk("keys"): |
|
14 for fn in files: |
|
15 ffn = os.path.join(root, fn) |
|
16 # FIXME: should ignore any path that contains dodgy characters |
|
17 keyname = ffn[5:] |
|
18 kf = open(ffn) |
|
19 try: |
|
20 for l in kf: |
|
21 command='cd repos && hgadmin/hg-ssh %s' % keyname |
|
22 prefix=('command="%s",no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding' |
|
23 % command) |
|
24 #prefix='no-port-forwarding,no-X11-forwarding,no-agent-forwarding' |
|
25 akeys.write("%s %s\n" % (prefix, l.strip())) |
|
26 finally: |
|
27 kf.close() |
|
28 |
|
29 os.rename(akeyfile + "_new", akeyfile) |
|
30 |