97 lines
4.1 KiB
Bash
97 lines
4.1 KiB
Bash
#!/usr/bin/bash
|
|
|
|
### <otsebyatina> for RPI
|
|
# quickstartsh="/usr/local/bin/quickstart.sh"
|
|
# cronline="@reboot $quickstartsh && crontab -l | grep -v $quickstartsh > /etc/crontab"
|
|
# cat quickstart.sh > $quickstartsh
|
|
# chown root:root $quickstartsh
|
|
# chmod u+x $quickstartsh
|
|
# echo $cronline >> /etc/crontab
|
|
### </otsebyatina>
|
|
|
|
print_ylw(){
|
|
echo -e "\033[33m$1\033[0m"
|
|
}
|
|
|
|
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 "[ install with docker ]"
|
|
packages="curl openssh-server iptables git nmap tcpdump net-tools wireguard tmux mc docker docker-compose"
|
|
else
|
|
print_ylw "[ install without docker ]"
|
|
packages="curl openssh-server iptables git nmap tcpdump net-tools wireguard tmux"
|
|
fi
|
|
}
|
|
|
|
function disable_ipv6 {
|
|
print_ylw "[ ipv6 turn off ]"
|
|
cat << EOF >> /etc/sysctl.conf
|
|
net.ipv6.conf.all.disable_ipv6=1
|
|
net.ipv6.conf.default.disable_ipv6=1
|
|
net.ipv4.ip_forward=1
|
|
EOF
|
|
sysctl -p
|
|
}
|
|
|
|
function sshd_cfg_bup {
|
|
print_ylw "[ sshd_config backup ]"
|
|
cat /etc/ssh/sshd_config > /etc/ssh/sshd_config_BUP
|
|
}
|
|
|
|
function sshd_config {
|
|
print_ylw "[ configuring sshd ]"
|
|
|
|
cat << EOF > /etc/ssh/sshd_config
|
|
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
|
|
EOF
|
|
}
|
|
|
|
function add_authorized_keys {
|
|
print_ylw "[ appending ssh-keys ]"
|
|
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDAPCabE6gKZkksoYdCCclvqBwPLMHM7Wasi3OtzgYmfyJzCPy2twMBZ35HbmuXd0oUE6IBScosGwgs3+5EQ/21b5BUosdZy82DDGG8vXwY2oxqd0U3GzebLmks8TRvdnZ2KXyMlbM9tB5lxrT8kaCdNWtj3Zbipjj2U6LDfvl9J5qojW4F7sNuh3qQ5T7FJA0R/X3F2K3VVk+ZD0PXy1pIauXck3K7iHtTjjHmBw73Ym0d+cg8MEOY7Y+tU4s8f2dOHN9VOSFONoYw0tOxUzZwYGNplEj3xDFUTsbm5wpWd6rGF9ilAqAnwB5Uwbq39ThikKi72PwIFr1e4QIf1AIOdci+yfrezZ/CwHw3AgaCY1PMbX50EZfa3Y9YhZH4bT7mVMCOVkOtIURiHEdcGeqjCe73eizTvDPE+0/xLPqIkJLI9Q4EeJESzRDNUkGiL6/L7Yi38pY+TqRz2dpyvuN9CHAmNPc9kmU9sdOOfAvSv7wGzTG3zB5NCU7UlWW3wPRYLTvYbRXHDROF8OlFjhLYGG6AYdJbNXTfQFHymKOJRjWiVaeBKMlAmhosdlEyRN1zYBb0bHdptEWpsqjv6mPQ3W20pS1h4zRT2P71TsA7UPlHTAeLgUuv9NW49VpdoKBId8cfJOmLesft1bGHfjgg8UNTbCpnOi0lRjoT4vxBPQ==" >> ~/.ssh/authorized_keys
|
|
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAEAQDMT0hLA/p00VWu98mPQg0aSe/9FbP/wCyg2YGGHEffFPs8zmfJAa6xIAFM3mIc2FhcNPOrAdbA/YpqxrA/3kf7G2JmaDSlRxlUeWXHvXk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I2bhbOr0iJEfBJzjVPcsB61M/VQ3xbt6+AET5wqAbZu1pVH+Dion4YyYjWy1DX802h2WNDvOzRwC82qeOUbZf3CTolBeKucdnLx5o8w9wsjxK80ArxRFx472Q45QkE61NLgcSfBHy+JywOxdP/fc0bwI/sFtAqEX5LCEkgqtB8r1w9bzCeeH u0_a294_trr"
|
|
}
|
|
|
|
function restart_sshd {
|
|
print_ylw "[ restart sshd ]"
|
|
systemctl restart sshd
|
|
}
|
|
|
|
function install_packages {
|
|
print_ylw "[ packages installation: $packages ]"
|
|
apt install $packages -y
|
|
}
|
|
|
|
|
|
disable_ipv6
|
|
sshd_cfg_bup
|
|
sshd_config
|
|
add_authorized_keys
|
|
restart_sshd
|
|
choose_packages
|
|
install_packages
|
|
|
|
print_ylw "[ DONE ]"
|