Add current user to allowed ssh users
This commit is contained in:
@@ -172,7 +172,12 @@ class WOSecureController(CementBaseController):
|
||||
break
|
||||
port = (ssh_line).split(' ')
|
||||
current_ssh_port = (port[1]).strip()
|
||||
data = dict(sshport=current_ssh_port, allowpass='no')
|
||||
if os.getenv('SUDO_USER'):
|
||||
sudo_user = os.environ['SUDO_USER']
|
||||
else:
|
||||
sudo_user = ''
|
||||
data = dict(sshport=current_ssh_port, allowpass='no',
|
||||
user=sudo_user)
|
||||
WOTemplate.render(self, '/etc/ssh/sshd_config',
|
||||
'sshd.mustache', data)
|
||||
WOGit.add(self, ["/etc/ssh"],
|
||||
|
||||
@@ -10,7 +10,7 @@ HostKey /etc/ssh/ssh_host_ed25519_key
|
||||
PermitRootLogin without-password
|
||||
|
||||
# Allow ssh access to some users only
|
||||
AllowUsers root ubuntu debian
|
||||
AllowUsers root ubuntu debian {{user}}
|
||||
|
||||
# allow ssh key Authentication
|
||||
PubkeyAuthentication yes
|
||||
|
||||
Reference in New Issue
Block a user