Skip to content

Commit

Permalink
Generate keypair by default (#486)
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Smith <[email protected]>
  • Loading branch information
sean-smith authored Nov 12, 2024
1 parent daca11f commit 0967936
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ class Config:
# You need to configure parameters in SssdConfig as well.
enable_sssd = False

# Set true to install quality-of-live improvements
enable_initsmhp = False

# Set true if you want to use mountpoint for s3 on cluster nodes.
# If enabled, a systemctl mount-s3.service file will be writen that will mount at /mnt/<BucketName>.
# requires s3 permissions to be added to cluster execution role.
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ def main(args):
ExecuteBashScript("./utils/motd.sh").run(node_type, ",".join(head_node_ip), ",".join(login_node_ip))
ExecuteBashScript("./utils/fsx_ubuntu.sh").run()
ExecuteBashScript("./start_slurm.sh").run(node_type, ",".join(controllers))
ExecuteBashScript("./utils/gen-keypair-ubuntu.sh").run()
ExecuteBashScript("./utils/ssh-to-compute.sh").run()

# Install metric exporting software and Prometheus for observability
if Config.enable_observability:
Expand Down Expand Up @@ -211,9 +213,6 @@ def main(args):
if Config.enable_sssd:
subprocess.run(["python3", "-u", "setup_sssd.py", "--node-type", node_type], check=True)

if Config.enable_initsmhp:
ExecuteBashScript("./initsmhp.sh").run(node_type)

if Config.enable_pam_slurm_adopt:
ExecuteBashScript("./utils/slurm_fix_plugstackconf.sh").run()
ExecuteBashScript("./utils/pam_adopt_cgroup_wheel.sh").run()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -exuo pipefail

mkdir -p /fsx/ubuntu/.ssh
cd /fsx/ubuntu/.ssh
{ test -f id_rsa && grep "^$(cat id_rsa.pub)$" authorized_keys &> /dev/null ; } && GENERATE_KEYPAIR=0 || GENERATE_KEYPAIR=1
if [[ $GENERATE_KEYPAIR == 1 ]]; then
echo Generate a new keypair...
ssh-keygen -t rsa -q -f id_rsa -N ""
cat id_rsa.pub >> authorized_keys
# Set permissions for the ssh keypair
chmod 600 id_rsa
chmod 644 id_rsa.pub
# Set permissions for the .ssh directory
chmod 700 /fsx/ubuntu/.ssh
# Change ownership to the ubuntu user
chown ubuntu:ubuntu id_rsa id_rsa.pub authorized_keys
chown ubuntu:ubuntu /fsx/ubuntu/.ssh
else
echo Use existing keypair...
fi

0 comments on commit 0967936

Please sign in to comment.