-
Notifications
You must be signed in to change notification settings - Fork 3
/
script.sh
executable file
·54 lines (40 loc) · 1.62 KB
/
script.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
#!/usr/bin/env bash
HOME="/root"
sudo apt-get update && sudo apt-get upgrade -y
# Remove existing OpenSSL
sudo apt-get purge --auto-remove openssl -y
sudo rm -rf /usr/include/openssl/
# Cleaning
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get install apt-utils wget tar gzip nano build-essential zlib1g-dev libssl-dev -y
# Optional
sudo apt-get install -y net-tools
# Python dependencies
sudo apt-get install python3 -y
sudo apt-get install python3-pip -y
sudo pip3 install paramiko
# SELinux && Pam
sudo apt-get install libpam0g-dev libselinux1-dev -y
# SSH directories
sudo mkdir -p /var/lib/sshd
sudo chmod -R 700 /var/lib/sshd/
sudo chown -R root:sys /var/lib/sshd/
sudo useradd -r -U -d /var/lib/sshd/ -c "sshd privsep" -s /bin/false sshd
# Install OpenSSL
cd $HOME || exit
wget --no-check-certificate https://www.openssl.org/source/old/1.0.2/openssl-1.0.2s.tar.gz
gzip -d openssl-1.0.2s.tar.gz && tar xvf openssl-1.0.2s.tar && cd openssl-1.0.2s || exit
./config && make && make test && sudo make install
# Install OpenSSH
cd $HOME || exit
wget --no-check-certificate https://ftp.rnl.tecnico.ulisboa.pt/pub/OpenBSD/OpenSSH/portable/openssh-7.9p1.tar.gz
gzip -d openssh-7.9p1.tar.gz && tar xvf openssh-7.9p1.tar && cd openssh-7.9p1 || exit
./configure --with-md5-passwords --with-pam --with-selinux --with-privsep-path=/var/lib/sshd/ --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/ssl
make && sudo make install
# Set root password
echo -e "qwerty\nqwerty" | sudo passwd
# Allow root login and start ssh
sed -i "s/#PermitRootLogin.*/PermitRootLogin yes/1" /etc/ssh/sshd_config
cd $HOME || exit
echo "Testing file" >>~/abc.txt