Skip to content

Commit

Permalink
Disallow root password login (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
lbgracioso committed Apr 12, 2024
1 parent bf04d29 commit 68d132c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/cloysterhpc/services/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Shell : public Execution {

void runSystemUpdate();
void installRequiredPackages();
void disallowSSHRootPasswordLogin();

void installOpenHPCBase();
void configureTimeService(const std::list<Connection>&);
Expand Down
9 changes: 9 additions & 0 deletions src/services/shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,14 @@ void Shell::installRequiredPackages()
runCommand("dnf -y install wget dnf-plugins-core");
}

void Shell::disallowSSHRootPasswordLogin()
{
LOG_INFO("Allowing root login only through public key authentication (SSH)")

runCommand("sed -i s/PermitRootLogin\\ yes/PermitRootLogin\\ "
"without-password/g /etc/ssh/sshd_config");
}

void Shell::installOpenHPCBase()
{
LOG_INFO("Installing base OpenHPC packages");
Expand Down Expand Up @@ -348,6 +356,7 @@ void Shell::install()
configureSELinuxMode();
configureFirewall();
configureFQDN();
disallowSSHRootPasswordLogin();

configureHostsFile();
configureTimezone();
Expand Down

0 comments on commit 68d132c

Please sign in to comment.