Skip to content

Commit

Permalink
Add chmod to write
Browse files Browse the repository at this point in the history
  • Loading branch information
zachhuff386 committed Mar 25, 2018
1 parent 1ec9d88 commit be199ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ssh_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
if known_hosts_modified:
print 'KNOWN_HOSTS: ' + known_hosts_path
with open(known_hosts_path_full, 'w') as known_file:
os.chmod(known_hosts_path_full, 0600)
known_file.write(known_hosts_data)

ssh_config_modified = False
Expand Down Expand Up @@ -230,6 +231,7 @@
if ssh_config_modified:
print 'SSH_CONFIG: ' + ssh_config_path
with open(ssh_config_path_full, 'w') as config_file:
os.chmod(ssh_config_path_full, 0600)
config_file.write(ssh_config_data)

print 'Successfully cleared strict host checking configuration'
Expand All @@ -254,6 +256,7 @@
if known_hosts_modified:
print 'KNOWN_HOSTS: ' + known_hosts_path
with open(known_hosts_path_full, 'w') as known_file:
os.chmod(known_hosts_path_full, 0600)
known_file.write(known_hosts_data)

ssh_config_modified = False
Expand Down Expand Up @@ -287,6 +290,7 @@
if ssh_config_modified:
print 'SSH_CONFIG: ' + ssh_config_path
with open(ssh_config_path_full, 'w') as config_file:
os.chmod(ssh_config_path_full, 0600)
config_file.write(ssh_config_data)

print 'Successfully cleared bastion host configuration'
Expand All @@ -310,6 +314,7 @@
if known_hosts_modified:
print 'KNOWN_HOSTS: ' + known_hosts_path
with open(known_hosts_path_full, 'w') as known_file:
os.chmod(known_hosts_path_full, 0600)
known_file.write(known_hosts_data)

ssh_config_modified = False
Expand All @@ -336,6 +341,7 @@
if ssh_config_modified:
print 'SSH_CONFIG: ' + ssh_config_path
with open(ssh_config_path_full, 'w') as config_file:
os.chmod(ssh_config_path_full, 0600)
config_file.write(ssh_config_data)

print 'Successfully cleared SSH configuration'
Expand Down Expand Up @@ -507,6 +513,7 @@
conf_keybase_state = True

with open(conf_path, 'w') as conf_file:
os.chmod(conf_path, 0600)
conf_file.write(json.dumps({
'server': conf_zero_server,
'public_key_path': conf_pub_key_path,
Expand Down Expand Up @@ -830,6 +837,7 @@ def factor_challenge(factor, passcode):
cert_hosts = cert_data.get('hosts')

with open(cert_path_full, 'w') as cert_file:
os.chmod(cert_path_full, 0600)
cert_file.write('\n'.join(certificates) + '\n')

print 'CERTIFICATE: ' + cert_path
Expand All @@ -852,6 +860,7 @@ def factor_challenge(factor, passcode):
if known_hosts_modified:
print 'KNOWN_HOSTS: ' + known_hosts_path
with open(known_hosts_path_full, 'w') as known_file:
os.chmod(known_hosts_path_full, 0600)
known_file.write(known_hosts_data)

ssh_config_modified = False
Expand Down Expand Up @@ -899,6 +908,7 @@ def factor_challenge(factor, passcode):
if ssh_config_modified:
print 'SSH_CONFIG: ' + ssh_config_path
with open(ssh_config_path_full, 'w') as config_file:
os.chmod(ssh_config_path_full, 0600)
config_file.write(ssh_config_data)

print 'Successfully validated SSH key'
2 changes: 2 additions & 0 deletions ssh_host_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@

def write_conf():
with open(CONF_PATH, 'w') as conf_file:
os.chmod(CONF_PATH, 0600)
conf_file.write(json.dumps({
'hostname': conf_hostname,
'server': conf_server,
Expand Down Expand Up @@ -474,6 +475,7 @@ def do_GET(self):

print('SSH_CERT: ' + cert_path)
with open(cert_path, 'w') as ssh_file:
os.chmod(cert_path, 0644)
ssh_file.write('\n'.join(certificates))

sys.exit(0)

0 comments on commit be199ce

Please sign in to comment.