moved around options

This commit is contained in:
2023-12-22 19:39:21 -06:00
parent 9747eba72b
commit 9801eaeeec

View File

@@ -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