Changeset - 74b7aa45c1e1
[Not reviewed]
stable
0 1 0
Mads Kiilerich (mads) - 6 years ago 2019-12-29 01:43:18
mads@kiilerich.com
Grafted from: c7ec47cb40e0
ssh: add WARNING comment as first line in .authorized_keys managed by Kallithea
1 file changed with 1 insertions and 0 deletions:
0 comments (0 inline, 0 general)
kallithea/model/ssh_key.py
Show inline comments
 
@@ -126,12 +126,13 @@ class SshKeyModel(object):
 
                        pass # Kallithea entries are ok to overwrite
 
                    else:
 
                        raise Exception("Safety check failed, found %r in %s - please review and remove it" % (l.strip(), authorized_keys))
 

	
 
        fh, tmp_authorized_keys = tempfile.mkstemp('.authorized_keys', dir=os.path.dirname(authorized_keys))
 
        with os.fdopen(fh, 'w') as f:
 
            f.write("# WARNING: This .ssh/authorized_keys file is managed by Kallithea. Manual editing or adding new entries will make Kallithea back off.\n")
 
            for key in UserSshKeys.query().join(UserSshKeys.user).filter(User.active == True):
 
                f.write(ssh.authorized_keys_line(kallithea_cli_path, config['__file__'], key))
 
        os.chmod(tmp_authorized_keys, stat.S_IRUSR | stat.S_IWUSR)
 
        # This preliminary remove is needed for Windows, not for Unix.
 
        # TODO In Python 3, the remove+rename sequence below should become os.replace.
 
        if os.path.exists(authorized_keys):
0 comments (0 inline, 0 general)