Skip to content

Commit d1fdb7e

Browse files
Mäki MikaAgenttiX
authored andcommitted
Reorganise SSH scripts
1 parent abfa82b commit d1fdb7e

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017-2024 Mika Mäki
3+
Copyright (c) 2017-2025 Mika Mäki
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

ssh/setup_ssh.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,4 @@ else
2323
ln -s "${CONF_DIR}" "${SSH_DIR}"
2424
fi
2525

26-
echo "Disabling password login."
27-
sudo sed -i "s@#PasswordAuthentication yes@PasswordAuthentication no@g" "/etc/ssh/sshd_config"
28-
sudo systemctl restart ssh
29-
30-
echo "Creating UFW firewall rule and enabling UFW."
31-
sudo ufw allow ssh comment SSH
32-
sudo ufw enable
33-
3426
echo "SSH configured."

ssh/setup_ssh_server.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
4+
if [ "${EUID}" -ne 0 ]; then
5+
echo "This script should be run as root."
6+
exit 1
7+
fi
8+
9+
echo "Disabling password login."
10+
sed -i "s@#PasswordAuthentication yes@PasswordAuthentication no@g" "/etc/ssh/sshd_config"
11+
systemctl restart ssh
12+
13+
if command -v &> /dev/null; then
14+
echo "Creating UFW firewall rule and enabling UFW."
15+
ufw allow ssh comment SSH
16+
ufw enable
17+
else
18+
echo "UFW was not found."
19+
fi

security/ssh-keygen.sh renamed to ssh/ssh-keygen.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#!/usr/bin/sh -e
1+
#!/usr/bin/env sh
2+
set -eu
23

34
# This script is trivial and mostly a note for myself.
45
# As of 2021, the default key length of ssh-keygen is 3072 bits, but

0 commit comments

Comments
 (0)