Skip to content

Commit

Permalink
Merge pull request #2213 from phillxnet/2212_(NG)_Authorized_keys_doe…
Browse files Browse the repository at this point in the history
…sn't_allow_public_key_ssh_login

[NG] - Authorized_keys doesn't allow public key ssh login. Fixes #2212
  • Loading branch information
phillxnet authored Sep 14, 2020
2 parents 5cff9e3 + 1d0e414 commit eff9a90
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/rockstor/system/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import random
import string
import crypt
import stat

import logging

Expand Down Expand Up @@ -233,7 +234,8 @@ def add_ssh_key(username, key, old_key=None):
if not os.path.isdir(SSH_DIR):
os.mkdir(SSH_DIR)
run_command([CHOWN, "-R", "%s:%s" % (username, groupname), SSH_DIR])
os.chmod(SSH_DIR, 700)
# Set directory to rwx --- --- (700) via stat constants.
os.chmod(SSH_DIR, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
fo, npath = mkstemp()
exists = False
with open(AUTH_KEYS, openmode) as afo, open(npath, "w") as tfo:
Expand All @@ -248,5 +250,6 @@ def add_ssh_key(username, key, old_key=None):
if exists:
return os.remove(npath)
move(npath, AUTH_KEYS)
os.chmod(AUTH_KEYS, 600)
# Set file to rw- --- --- (600) via stat constants.
os.chmod(AUTH_KEYS, stat.S_IRUSR | stat.S_IWUSR)
run_command([CHOWN, "%s:%s" % (username, groupname), AUTH_KEYS])

0 comments on commit eff9a90

Please sign in to comment.