From 9801eaeeec6006bb23bbbdc8da36e43492ce94d3 Mon Sep 17 00:00:00 2001 From: akanealw Date: Fri, 22 Dec 2023 19:39:21 -0600 Subject: [PATCH] moved around options --- debian/debian-configure-sshd.sh | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/debian/debian-configure-sshd.sh b/debian/debian-configure-sshd.sh index 52b9108..10d3148 100644 --- a/debian/debian-configure-sshd.sh +++ b/debian/debian-configure-sshd.sh @@ -1,20 +1,20 @@ #!/bin/bash if [ "$EUID" -ne 0 ] - then - echo "Please run as root" - exit + then + echo "Please run as root" + exit fi # sshd config +cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak > /dev/null 2>&1 isInFile=$(cat /etc/hostname | grep -c "proxmox") if [ $isInFile -eq 0 ] then isInFile=$(cat /etc/ssh/sshd_config | grep -c "#PermitRootLogin prohibit-password") if [ $isInFile -eq 0 ] then - cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak1 > /dev/null 2>&1 sed -i 's/PermitRootLogin no/#PermitRootLogin prohibit-password/g' /etc/ssh/sshd_config sed -i 's/PermitRootLogin yes/#PermitRootLogin prohibit-password/g' /etc/ssh/sshd_config sed -i 's/PermitRootLogin prohibit-password/#PermitRootLogin prohibit-password/g' /etc/ssh/sshd_config @@ -27,7 +27,6 @@ if [ $isInFile -eq 0 ] isInFile=$(cat /etc/ssh/sshd_config | grep -c "PasswordAuthentication no") if [ $isInFile -eq 0 ] then - cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak2 > /dev/null 2>&1 sed -i 's/#PasswordAuthentication no/PasswordAuthentication no/g' /etc/ssh/sshd_config sed -i 's/PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config @@ -36,7 +35,7 @@ fi # authorized_keys akanealw -cp /home/akanealw/.ssh/authorized_keys /home/akanealw/.ssh/authorized_keys.bak +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") if [ $isInFile -eq 0 ] then @@ -79,8 +78,7 @@ if [ $isInFile -eq 0 ] mv /home/akanealw/.ssh/known_hosts /home/akanealw/.ssh/known_hosts.old echo "" >> /home/akanealw/.ssh/config echo "" >> /home/akanealw/.ssh/config - echo "Host *root" >> /home/akanealw/.ssh/config - echo "Port 22" >> /home/akanealw/.ssh/config + echo "Host *-root" >> /home/akanealw/.ssh/config echo "User root" >> /home/akanealw/.ssh/config echo "IdentityFile /root/.ssh/server-root" >> /home/akanealw/.ssh/config echo "" >> /home/akanealw/.ssh/config @@ -101,8 +99,7 @@ if [ $isInFile -eq 0 ] mv /root/.ssh/known_hosts /root/.ssh/known_hosts.old echo "" >> /root/.ssh/config echo "" >> /root/.ssh/config - echo "Host *root" >> /root/.ssh/config - echo "Port 22" >> /root/.ssh/config + echo "Host *-root" >> /root/.ssh/config echo "User root" >> /root/.ssh/config echo "IdentityFile /root/.ssh/server-root" >> /root/.ssh/config echo "" >> /root/.ssh/config