2024-08-04 09:36:48 +00:00
|
|
|
#!/usr/bin/bash
|
|
|
|
|
2024-08-06 08:45:42 +00:00
|
|
|
print_ylw(){
|
|
|
|
echo -e "\033[33m$1\033[0m"
|
|
|
|
}
|
|
|
|
|
2024-11-13 21:41:36 +00:00
|
|
|
function is_x64 {
|
|
|
|
print_ylw "[ determine architecture ]"
|
|
|
|
arch=$(lscpu | grep -i architecture | cut -d ":" -f2)
|
|
|
|
if [ $arch != "x86_64" ]; then
|
|
|
|
false
|
|
|
|
else
|
|
|
|
true
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function choose_packages {
|
|
|
|
if is_x64 ; then
|
|
|
|
print_ylw "[ with docker ]"
|
|
|
|
packages="curl git nmap tcpdump net-tools wireguard tmux mc docker docker-compose"
|
|
|
|
else
|
|
|
|
print "[ without docker ]"
|
|
|
|
packages="curl git nmap tcpdump net-tools wireguard tmux"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function disable_ipv6 {
|
2024-08-06 08:45:42 +00:00
|
|
|
print_ylw "[ ipv6 turn off ]"
|
2024-08-12 08:07:25 +00:00
|
|
|
cat << EOF >> /etc/sysctl.conf
|
2024-11-13 21:04:35 +00:00
|
|
|
net.ipv6.conf.all.disable_ipv6=1
|
|
|
|
net.ipv6.conf.default.disable_ipv6=1
|
2024-08-12 08:07:25 +00:00
|
|
|
net.ipv4.ip_forward=1
|
|
|
|
EOF
|
2024-08-06 08:07:44 +00:00
|
|
|
sysctl -p
|
2024-11-13 21:41:36 +00:00
|
|
|
}
|
2024-08-06 08:07:44 +00:00
|
|
|
|
2024-11-13 21:41:36 +00:00
|
|
|
function sshd_cfg_bup {
|
2024-08-06 08:45:42 +00:00
|
|
|
print_ylw "[ sshd_config backup ]"
|
2024-08-04 10:15:32 +00:00
|
|
|
cat /etc/ssh/sshd_config > /etc/ssh/sshd_config_BUP &&
|
2024-11-13 21:41:36 +00:00
|
|
|
}
|
2024-08-04 09:58:05 +00:00
|
|
|
|
2024-11-13 21:41:36 +00:00
|
|
|
function sshd_config {
|
2024-08-06 08:45:42 +00:00
|
|
|
print_ylw "[ configuring sshd ]"
|
2024-08-04 10:09:18 +00:00
|
|
|
|
|
|
|
cat << EOF > /etc/ssh/sshd_config
|
2024-08-04 09:58:05 +00:00
|
|
|
Include /etc/ssh/sshd_config.d/*.conf
|
|
|
|
Port 22
|
|
|
|
ListenAddress 0.0.0.0
|
|
|
|
PermitRootLogin yes
|
|
|
|
PubkeyAuthentication yes
|
|
|
|
PasswordAuthentication no
|
|
|
|
PermitEmptyPasswords no
|
|
|
|
KbdInteractiveAuthentication no
|
|
|
|
UsePAM yes
|
|
|
|
X11Forwarding yes
|
|
|
|
PrintMotd no
|
|
|
|
AcceptEnv LANG LC_*
|
|
|
|
Subsystem sftp /usr/lib/openssh/sftp-server
|
2024-08-04 10:10:25 +00:00
|
|
|
EOF
|
2024-11-13 21:41:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function add_authorized_keys {
|
|
|
|
print_ylw "[ appending ssh-keys ]"
|
|
|
|
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDAPCabE6gKZkksoYdCCclvqBwPLMHM7Wasi3OtzgYmfyJzCPy2twMBZ35HbmuXd0oUE6IBScosGwgs3+5EQ/21b5BUosdZy82DDGG8vXwY2oxqd0U3GzebLmks8TRvdnZ2KXyMlbM9tB5lxrT8kaCdNWtj3Zbipjj2U6LDfvl9J5qojW4F7sNuh3qQ5T7FJA0R/X3F2K3VVk+ZD0PXy1pIauXck3K7iHtTjjHmBw73Ym0d+cg8MEOY7Y+tU4s8f2dOHN9VOSFONoYw0tOxUzZwYGNplEj3xDFUTsbm5wpWd6rGF9ilAqAnwB5Uwbq39ThikKi72PwIFr1e4QIf1AIOdci+yfrezZ/CwHw3AgaCY1PMbX50EZfa3Y9YhZH4bT7mVMCOVkOtIURiHEdcGeqjCe73eizTvDPE+0/xLPqIkJLI9Q4EeJESzRDNUkGiL6/L7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CoDwBkXqZudLdlXULRsaEuYo+HaGjBug0dQRYbFTllj52ypnjfeiWRP6yvvlcLHT3GpDbbW8kzMXlwYmlyQQbgQf/Z4cU10PHqJbGOlQlEgN7gUsAI+Isl9UaEx5haDnXapbM4PFxGzhtjZ+YuIMYC8b19oXjKm0oLZhwN3S/vB54pPnmb3OQH+vc6pMZPeHX6G3sH9vwVe1qYlBspV5ICVrpV27j4f7cnCH7MJpcanw3VHqcSn0gC30EQBbi+iCOyMJZy2x0P2FZ8W5dvIarewoUu/dTkQ+hGea5Cs4wSW53YhEK0rEKr8HYRXhmrEtnf4B8MhJ5DGBzHueKOYAM5BdwXp7GU4xPGWq5g0kTCSqGOQJWVDOdYyqsdhNned2rg+HybVDyb+XaF8j3aa48qN02I2bhbOr0iJEfBJzjVPcsB61M/VQ3xbt6+AET5wqAbZu1pVH+Dion4YyYjWy1DX802h2WNDvOzRwC82qeOUbZf3CTolBeKucdnLx5o8w9wsjxK80ArxRFx472Q45QkE61NLgcSfBHy+JywOxdP/fc0bwI/sFtAqEX5LCEkgqtB8r1w9bzCeeH u0_a294@poco"
|
|
|
|
}
|
2024-08-04 09:58:05 +00:00
|
|
|
|
2024-11-13 21:41:36 +00:00
|
|
|
function restart_sshd {
|
|
|
|
print_ylw "[ restart sshd ]"
|
|
|
|
systemctl restart sshd
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_packages {
|
|
|
|
print_ylw "[ packages installation: $packages ]"
|
|
|
|
apt install $packages
|
|
|
|
}
|
2024-08-04 09:58:05 +00:00
|
|
|
|
2024-08-06 07:51:13 +00:00
|
|
|
|
2024-11-13 21:41:36 +00:00
|
|
|
disable_ipv6
|
|
|
|
sshd_cfg_bup
|
|
|
|
sshd_config
|
|
|
|
add_authorized_keys
|
|
|
|
restart_sshd
|
|
|
|
choose_packages
|
|
|
|
install_packages
|
2024-08-04 09:58:05 +00:00
|
|
|
|
2024-08-08 19:11:40 +00:00
|
|
|
print_ylw "[ DONE ]"
|