Syncing latest changes between public/private.

This commit is contained in:
Eric Froemling 2020-03-25 20:00:14 -07:00
parent b81cf9d77d
commit 51e7c32d1c
2 changed files with 22 additions and 6 deletions

View File

@ -312,6 +312,7 @@
<w>confighash</w>
<w>configkey</w>
<w>configparser</w>
<w>configpath</w>
<w>connectattr</w>
<w>containerwidget</w>
<w>contentmanager</w>

View File

@ -575,6 +575,25 @@ def push_ipa() -> None:
ios.push_ipa(root, modename)
def fix_mac_ssh() -> None:
"""Turn off mac ssh password access.
(This totally doesn't belong in this project btw..)
"""
configpath = '/etc/ssh/sshd_config'
with open(configpath) as infile:
lines = infile.readlines()
index = lines.index('#PasswordAuthentication yes\n')
lines[index] = 'PasswordAuthentication no\n'
index = lines.index('#ChallengeResponseAuthentication yes\n')
lines[index] = 'ChallengeResponseAuthentication no\n'
index = lines.index('UsePAM yes\n')
lines[index] = 'UsePAM no\n'
with open(configpath, 'w') as outfile:
outfile.write(''.join(lines))
print('SSH config updated successfully!')
def check_mac_ssh() -> None:
"""Make sure ssh password access is turned off.
@ -585,12 +604,8 @@ def check_mac_ssh() -> None:
lines = infile.read().splitlines()
if ('UsePAM yes' in lines or '#PasswordAuthentication yes' in lines
or '#ChallengeResponseAuthentication yes' in lines):
print('ERROR: ssh config is allowing password access\n'
'To fix: sudo emacs -nw /etc/ssh/sshd_config\n'
'"#PasswordAuthentication yes" -> "PasswordAuthentication no"\n'
'"#ChallengeResponseAuthentication yes" -> '
'"ChallengeResponseAuthentication no"\n'
'"UsePam yes" -> "UsePam no"\n')
print('ERROR: ssh config is allowing password access.\n'
'To fix: sudo tools/snippets fix_mac_ssh')
sys.exit(255)
print('password ssh auth seems disabled; hooray!')