diff options
| author | Craig Jennings <c@cjennings.net> | 2024-11-22 18:28:22 -0600 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-11-22 18:28:22 -0600 |
| commit | e19784e8c4443185297946262a7b737228f6ee58 (patch) | |
| tree | 1c19cd830d9f8c050f38a949f3d35def4dd1c0f8 /archsshd | |
| parent | 9a295d73c48924492ec22ae0cf3873c4c0d620f4 (diff) | |
adding archsshd script
Diffstat (limited to 'archsshd')
| -rw-r--r-- | archsshd | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/archsshd b/archsshd new file mode 100644 index 0000000..4687566 --- /dev/null +++ b/archsshd @@ -0,0 +1,52 @@ +#!/bin/sh + +# archsshd +# Craig Jennings <c@cjennings.net> +# Sets up keys and sshd daemon on arch live cd + +check_root_or_exit () { + if [ "$EUID" -ne 0 ] + then echo "Please run as root" + exit + fi +} + +retrieve_keys() { + # retrieve keys from repo and decrypt + echo "retrieving keys for decryption..." + { + mkdir -p "$HOME/.ssh/" + # retrieve keys from dotfiles repo and decrypt the keys + (git clone --depth 1 https://git.cjennings.net/dotfiles.git \ + "$HOME/dotfiles/") >> /dev/null + cp "$HOME/dotfiles/system/.ssh/*" "$HOME/.ssh/" + rm -rf "$HOME/dotfiles/" + } > /dev/null + cd "$HOME/.ssh/" + gpg --decrypt "$HOME/ssh.tar.gz.gpg" | tar -zxf - + + # set proper permissions on .ssh directory + cd "$HOME" && chmod 600 $HOME/.ssh/* && chmod 700 $HOME/.ssh \ + && chmod 644 $HOME/.ssh/*.pub +) + +setup_ssh () { + # setup ssh + echo "setting up ssh daemon..." + systemctl start sshd + echo "root:welcome" | chpasswd + hostname=$(</etc/hostname) + ipaddress=$(ip addr show wlan0 | grep 'inet ' | awk '{print $2}' | cut -d/ -f1) + + # notify user + echo ""; echo "" + echo "you may ssh root@$hostname or ssh root@$ipaddress using the password 'welcome'" +} + + + +### SCRIPT ### + +check_root_or_exit +retrieve_keys +setup_ssh |
