Skip to content

Instantly share code, notes, and snippets.

@kwharrigan
Created March 20, 2012 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kwharrigan/2140926 to your computer and use it in GitHub Desktop.
Save kwharrigan/2140926 to your computer and use it in GitHub Desktop.
Split up a single openssl authorized keys file into multiple files, suitable for gitolite
#!/bin/python
import sys
import os
filename = sys.argv[1]
fh = open(filename, 'r')
line = fh.readline()
ct = 0
while line != '':
ct += 1
keydir = 'key%d' % ct
if not os.path.exists(keydir):
os.mkdir(keydir)
wf = open('key%d/%s.pub' % (ct, filename), 'w')
wf.write(line)
line = fh.readline()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment