2017-05-04 03:25:20 -04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2017-05-04 13:39:16 -04:00
|
|
|
import os
|
|
|
|
from urllib.request import urlopen
|
|
|
|
|
|
|
|
# You'll probably definitely want to change this. Unless you want to give me SSH access.
|
|
|
|
keyfile = 'https://square-r00t.net/ssh/all'
|
|
|
|
|
|
|
|
keydir = '/root/.ssh'
|
|
|
|
|
|
|
|
os.makedirs(keydir, exist_ok = True)
|
|
|
|
os.chown(keydir, 0, 0)
|
|
|
|
os.chmod(keydir, 0o700)
|
|
|
|
|
2017-05-04 13:48:53 -04:00
|
|
|
with open('{0}/authorized_keys'.format(keydir), 'w') as f:
|
2017-05-04 13:39:16 -04:00
|
|
|
with urlopen(keyfile) as url:
|
|
|
|
f.write(url.read().decode('utf-8'))
|
|
|
|
|
2017-05-04 13:48:53 -04:00
|
|
|
os.chown('{0}/authorized_keys'.format(keydir), 0, 0)
|
|
|
|
os.chmod('{0}/authorized_keys'.format(keydir), 0o600)
|