-
Notifications
You must be signed in to change notification settings - Fork 5
/
setupvps.sh
83 lines (74 loc) · 2.49 KB
/
setupvps.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#to run: bash setupvps.sh
read -r -p "Do you want to update system and install nano, wget and sudo? [Y/n]" response
response=${response,,} # tolower
if [[ $response =~ ^(yes|y| ) ]]; then
apt-get -y update
apt-get -y install nano
apt-get -y install wget
apt-get -y install sudo
cd
fi
read -r -p "Do you want to adduser ympker? [Y/n]" response
response=${response,,} # tolower
if [[ $response =~ ^(yes|y| ) ]]; then
sudo adduser ympker
sudo adduser ympker sudo
printf "Done. User Ympker was added to sudoers group"
fi
read -r -p "Do you want to install OpenSSH Server? [Y/n]" response
response=${response,,} # tolower
if [[ $response =~ ^(yes|y| ) ]]; then
sudo apt-get -y install openssh-server
sudo systemctl enable ssh
sudo systemctl start ssh
sudo systemctl status ssh
printf "You have successfully installed OpenSSH server. Remember to change SSH Port"
fi
read -r -p "Do you want to restart SSH and SSHD? [Y/n]" response
response=${response,,} # tolower
if [[ $response =~ ^(yes|y| ) ]]; then
sudo service ssh restart
sudo service ssh status
sudo service sshd restart
sudo service sshd status
printf "Done."
#copy setup file to home directory of ympker and make it executable so you can pick up where you stopped when switching users
cp setupvps.sh /home/ympker/setupvps.sh
cd /home/ympker
chmod +x setupvps.sh
fi
read -r -p "Do you want to add your SSH Key to user ympker? SWITCH TO user ympker before proceeding [Y/n]" response
response=${response,,} # tolower
if [[ $response =~ ^(yes|y| ) ]]; then
cd
mkdir -p ~/.ssh
echo test >> ~/.ssh/authorized_keys
chmod -R go= ~/.ssh
cd .ssh
sudo nano authorized_keys
sudo service ssh restart
sudo service sshd restart
printf "Done. Public Key added."
fi
read -r -p "Do you want to edit SSHD config? [Y/n]" response
response=${response,,} # tolower
if [[ $response =~ ^(yes|y| ) ]]; then
sudo nano /etc/ssh/sshd_config
#change port
#add
#PermitRootLogin no
#MaxAuthTries 3
#PubkeyAuthentication yes
#PasswordAuthentication no
#ChallengeResponseAuthentication no
printf "Done."
fi
read -r -p "Do you want to restart SSH and SSHD? [Y/n]" response
response=${response,,} # tolower
if [[ $response =~ ^(yes|y| ) ]]; then
sudo systemctl restart ssh
service ssh restart
sudo service sshd restart
sudo service sshd status
printf "Done."
fi