Files
linux-scripts/debian/debian-configure-sshd.sh
2023-12-21 19:17:36 -06:00

73 lines
2.6 KiB
Bash

#!/bin/bash
if [ "$EUID" -ne 0 ]
then
echo "Please run as root"
exit
fi
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
sed -i 's/PermitRootLogin yes/#PermitRootLogin prohibit-password/g' /etc/ssh/sshd_config
fi
fi
isInFile=$(cat /etc/hostname | grep -c "proxmox")
if [ $isInFile -eq 0 ]
then
isInFile=$(cat /etc/ssh/sshd_config | grep -c "PasswordAuthentication no")
if [ $isInFile -eq 0 ]
then
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config
fi
fi
isInFile=$(cat /home/akanealw/.ssh/authorized_keys | grep -c "gamingpc-akanealw")
if [ $isInFile -eq 0 ]
then
echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINRfrcCbyeG7O7P3/WNuPrOr131x/DHcJqjJVE/BBrAU gamingpc-akanealw" >> /home/akanealw/.ssh/authorized_keys
chown akanealw:akanealw /home/akanealw/.ssh/*
chmod 600 /home/akanealw/.ssh/*
fi
isInFile=$(cat /home/akanealw/.ssh/authorized_keys | grep -c "laptoppc-akanealw")
if [ $isInFile -eq 0 ]
then
echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAj1SSffm3S3wJCSq3YjGzQ/Gw3Ta9YRzUmSvxv4/bVm laptoppc-akanealw" >> /home/akanealw/.ssh/authorized_keys
chown akanealw:akanealw /home/akanealw/.ssh/*
chmod 600 /home/akanealw/.ssh/*
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
chown akanealw:akanealw /home/akanealw/.ssh/*
chmod 600 /home/akanealw/.ssh/*
fi
isInFile=$(cat /root/.ssh/authorized_keys | grep -c "gaminpc-root")
if [ $isInFile -eq 0 ]
then
echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILMb59HWxAoetRy+Qd0IWrF79z6iwq/JcL2cJ8rRI4Io gamingpc-root" >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
fi
isInFile=$(cat /root/.ssh/authorized_keys | grep -c "laptoppc-root")
if [ $isInFile -eq 0 ]
then
echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIL3BxOpdWBLaZKL/EKIRIypK91hFvYE7Ak2fgDEiPmHE laptoppc-root" >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
fi
isInFile=$(cat /root/.ssh/authorized_keys | grep -c "server-root")
if [ $isInFile -eq 0 ]
then
echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHWiw5lVzQIZiZc1SPphvHhdSpFl9UN6Xm4znFqq5xs4 server-root" >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
fi