manually enter ssh port
This commit is contained in:
parent
5436760bf6
commit
8948238b45
|
|
@ -2,7 +2,21 @@
|
|||
|
||||
echo -e "${PURPLE}${BOLD}Setup SSH${RESET}"
|
||||
|
||||
SSH_PORT=$((RANDOM % (65536 - 1024 + 1) + 1024))
|
||||
echo -e "${PURPLE}${BOLD}Do you want to manually set the SSH port? (y/N)${RESET}"
|
||||
read answer
|
||||
|
||||
if [[ "$answer" == "y" ]]; then
|
||||
echo -e "${PURPLE}${BOLD}Enter the desired SSH port (between 1024 and 65535):${RESET}"
|
||||
read port
|
||||
if [[ "$port" =~ ^[0-9]+$ ]] && [ "$port" -ge 1024 ] && [ "$port" -le 65535 ]; then
|
||||
SSH_PORT=$port
|
||||
else
|
||||
SSH_PORT=$((RANDOM % (65536 - 1024 + 1) + 1024))
|
||||
echo -e "${ORANGE}${BOLD}Invalid port number. Using random port instead.${RESET}"
|
||||
fi
|
||||
else
|
||||
SSH_PORT=$((RANDOM % (65536 - 1024 + 1) + 1024))
|
||||
fi
|
||||
|
||||
touch /etc/ssh/sshd_config.d/custom.conf
|
||||
echo "PermitRootLogin no" >> /etc/ssh/sshd_config.d/custom.conf
|
||||
|
|
@ -10,4 +24,4 @@ echo "PermitEmptyPasswords no" >> /etc/ssh/sshd_config.d/custom.conf
|
|||
echo "Port ${SSH_PORT}" >> /etc/ssh/sshd_config.d/custom.conf
|
||||
systemctl reload ssh
|
||||
|
||||
echo -e "${ORANGE}${BOLD}Store the ssh port ${SSH_PORT} somewhere safe${RESET}"
|
||||
echo -e "${ORANGE}${BOLD}Store the ssh port ${SSH_PORT} somewhere safe${RESET}"
|
||||
|
|
|
|||
Loading…
Reference in New Issue