add ssh-keygen.sh and ssh-enhancer.sh

This commit is contained in:
Dita Aji Pratama 2024-05-30 19:45:36 +07:00
parent 30c2c1055f
commit 083ef2de53
2 changed files with 23 additions and 0 deletions

22
shell/ssh-enhancer.sh Normal file
View File

@ -0,0 +1,22 @@
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: sudo bash $0 <port>"
exit 1
fi
port=$1
# Check if the port is a number
if ! [[ "$port" =~ ^[0-9]+$ ]]; then
echo "Error: Port must be a number."
exit 1
fi
# Create a new sshd_config file with 99- prefix in /etc/ssh/sshd_config.d/ directory
echo -e "Port $port\nPasswordAuthentication no" | sudo tee /etc/ssh/sshd_config.d/99-custom_ssh_port.conf > /dev/null
# Restart SSH service to apply changes
sudo systemctl restart sshd
echo "SSH port changed to $port and password authentication disabled."

1
shell/ssh-keygen.sh Normal file
View File

@ -0,0 +1 @@
ssh-keygen -t rsa -b 4096