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)
|
|
|
|
|
|
|
|
with open('{0}/authorized_keys', 'w') as f:
|
|
|
|
with urlopen(keyfile) as url:
|
|
|
|
f.write(url.read().decode('utf-8'))
|
|
|
|
|
|
|
|
os.chown('{0}/authorized_keys', 0, 0)
|
|
|
|
os.chmod('{0}/authorized_keys', 0o600)
|