diff --git a/alpine/alpine-essentials.sh b/alpine/alpine-essentials.sh index 6ebfb8b..affbe02 100755 --- a/alpine/alpine-essentials.sh +++ b/alpine/alpine-essentials.sh @@ -34,6 +34,33 @@ if [[ ! -f /etc/sudoers.d/akanealw ]] echo "akanealw ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/akanealw fi +# add ssh keys for akanealw +mkdir /home/akanealw/.ssh > /dev/null 2>&1 +cp /home/akanealw/.ssh/authorized_keys /home/akanealw/.ssh/authorized_keys.bak > /dev/null 2>&1 + +isInFile=$(cat /home/akanealw/.ssh/authorized_keys | grep -c "winpc-akanealw") > /dev/null 2>&1 + if [ $isInFile -eq 0 ]; then + echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBKYj+eRQsvdLvrJNoqugb9A7iQT+BEPb6LI9BseyhWR winpc-akanealw" >> /home/akanealw/.ssh/authorized_keys + fi + +isInFile=$(cat /home/akanealw/.ssh/authorized_keys | grep -c "server-akanealw") + if [ $isInFile -eq 0 ]; then + echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGAiw0sQxxTg/zBm/Hz4LLjtiuGfefF2vogGkYcWox4S server-akanealw" >> /home/akanealw/.ssh/authorized_keys + fi +chown akanealw:akanealw /home/akanealw/.ssh/ +chown akanealw:akanealw /home/akanealw/.ssh/* +chmod 600 /home/akanealw/.ssh/* + +# disable ssh password login +cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak +sed -i "/#PasswordAuthentication yes/c\PasswordAuthentication no" /etc/ssh/sshd_config + +# enable and start sshd +if [[ -f /etc/init.d/sshd ]]; then + rc-update add sshd > /dev/null 2>&1 + rc-service sshd start > /dev/null 2>&1 +fi + # edit issue file isInFile=$(cat /etc/issue | grep -c "192.168.1") if [ $isInFile -eq 0 ] @@ -44,31 +71,3 @@ fi # remove all motd rm /etc/motd > /dev/null 2>&1 - -# add ssh keys for akanealw -if [[ -d /home/akanealw ]]; then - mkdir /home/akanealw/.ssh > /dev/null 2>&1 - cp /home/akanealw/.ssh/authorized_keys /home/akanealw/.ssh/authorized_keys.bak > /dev/null 2>&1 - isInFile=$(cat /home/akanealw/.ssh/authorized_keys | grep -c "winpc-akanealw") > /dev/null 2>&1 - if [ $isInFile -eq 0 ]; then - echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBKYj+eRQsvdLvrJNoqugb9A7iQT+BEPb6LI9BseyhWR winpc-akanealw" >> /home/akanealw/.ssh/authorized_keys - fi - - isInFile=$(cat /home/akanealw/.ssh/authorized_keys | grep -c "server-akanealw") - if [ $isInFile -eq 0 ]; then - echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGAiw0sQxxTg/zBm/Hz4LLjtiuGfefF2vogGkYcWox4S server-akanealw" >> /home/akanealw/.ssh/authorized_keys - fi - chown akanealw:akanealw /home/akanealw/.ssh/ - chown akanealw:akanealw /home/akanealw/.ssh/* - chmod 600 /home/akanealw/.ssh/* -fi - -# disable ssh password login -cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak -sed -i "/#PasswordAuthentication yes/c\PasswordAuthentication no" /etc/ssh/sshd_config - -# enable and start sshd -if [[ -f /etc/init.d/sshd ]]; then - rc-update add sshd - rc-service sshd start -fi