david/scripts-archive
david
/
scripts-archive
Archived
1
0
Fork 0
This repository has been archived on 2022-04-16. You can view files and clone it, but cannot push or open issues or pull requests.
scripts-archive/prep_ubuntu_server.sh

84 lines
1.5 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
# preperation script for my ubuntu servers
# **** configuration section ****
sshgroup="sshusers"
#user=$(cat /etc/passwd | grep 1000)
#user=${user:0:$(($(echo `expr index "$user" :`)-1))}
user="david"
# **** install various tools/packages ****
pkginstall()
{
apt-get update
apt-get dist-upgrade -y
apt-get install -y htop nload nmap tshark git-core \
curl wget dnsutils \
vim zsh ncdu
}
# **** configure motd ****
motdconfig()
{
rm /etc/update-motd.d/00*
rm /etc/update-motd.d/10*
rm /etc/update-motd.d/50*
echo ""
read -p "now its time to create/customize your /etc/motd.tail
(go to http://www.network-science.de/ascii/)"
vim /etc/motd.tail
}
# **** ssh server config ****
sshdconfig()
{
echo "
__.-._
'-._'7'
/'.-c
| /T
_)_/LI
this machine is
protected by a
master of the force!
" > /etc/issue.net
sed -i 's/#Banner/Banner/' /etc/ssh/sshd_config
echo "" >> /etc/ssh/sshd_config
echo "# Restrictions added by ubuntu server prep script" >> /etc/ssh/sshd_config
echo "AllowGroups $sshgroup" >> /etc/ssh/sshd_config
echo "" >> /etc/ssh/sshd_config
addgroup $sshgroup
adduser $user $sshgroup
read -p "add needed users to sshgroup $sshgroup in /etc/group"
vim /etc/group
}
# **** start of script ****
pkginstall
motdconfig
sshdconfig
exit 0
# **** end of file ****