forked from gurubamal/success_taste
-
Notifications
You must be signed in to change notification settings - Fork 0
/
set_ssh.sh
35 lines (29 loc) · 1.14 KB
/
set_ssh.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
#
if ! grep 192.168.58 /etc/hosts
then
echo 192.168.58.7 node7 node02| sudo tee -a /etc/hosts
echo 192.168.58.8 node8 node03| sudo tee -a /etc/hosts
echo 192.168.58.6 node6 node01| sudo tee -a /etc/hosts
echo 192.168.58.5 node5 controller| sudo tee -a /etc/hosts
fi
if ! grep "PasswordAuthentication yes" /etc/ssh/sshd_config
then
sudo sed -i "s/\#PasswordAuthentication yes/PasswordAuthentication yes/g" /etc/ssh/sshd_config
echo "PasswordAuthentication yes" |sudo tee -a /etc/ssh/sshd_config
sudo sed -i 's/PasswordAuthentication\ no/PasswordAuthentication\ yes/g' /etc/ssh/sshd_config
fi
if ! grep "PermitRootLogin yes" /etc/ssh/sshd_config
then
echo "PermitRootLogin yes" |sudo tee -a /etc/ssh/sshd_config
fi
if ! grep "StrictHostKeyChecking no" /etc/ssh/ssh_config
then
echo "StrictHostKeyChecking no" |sudo tee -a /etc/ssh/ssh_config
fi
sudo systemctl restart ssh
FILEX=/home/vagrant/x.txt
if test -f "$FILEX"; then
echo "Password was reset already"
else
echo -e "vagrant\nvagrant" | sudo passwd root ; touch $FILEX
fi