-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_ssh_server.sh
37 lines (32 loc) · 1.06 KB
/
install_ssh_server.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
#!/bin/bash#
# Setup public - private key
mkdir -p /kaggle/working/.ssh
echo $1
FILE=/kaggle/working/.ssh/authorized_keys
if test -f "$FILE";
then
wget $1 -O /kaggle/working/.ssh/temp
cat /kaggle/working/.ssh/temp >> /kaggle/working/.ssh/authorized_keys
rm /kaggle/working/.ssh/temp
else
wget $1 -O /kaggle/working/.ssh/authorized_keys
fi
chmod 700 /kaggle/working/.ssh
chmod 600 /kaggle/working/.ssh/authorized_keys
# Download ngrok
FILE=/kaggle/working/SSH/ngrok
if ! test -f "$FILE";
then
wget https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz
sudo tar xvzf ngrok-v3-stable-linux-amd64.tgz -C /usr/local/bin
rm ngrok-v3-stable-linux-amd64.tgz
fi
# Install SSH-Server
sudo apt update
sudo apt install openssh-server -y
# SSH Config
sudo echo "PermitRootLogin no" >> /etc/ssh/sshd_config
sudo echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
sudo echo "AuthorizedKeysFile /kaggle/working/.ssh/authorized_keys" >> /etc/ssh/sshd_config
sudo echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config
sudo service ssh restart