Skip to content

Commit c0dc311

Browse files
committed
Added SSH changes.
1 parent a9dd47c commit c0dc311

File tree

3 files changed

+23
-37
lines changed

3 files changed

+23
-37
lines changed

terra/README.md

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,22 @@ This folder contains the scripts that streamline the setting up of a validator i
77
Before running any of the scripts, if you are starting from a new server as root, the first thing to do is to create a non-root user.
88

99
```
10-
USER=terrau
11-
useradd -m -s /bin/bash $USER
12-
usermod -aG sudo $USER
13-
# Set the password for the user.
14-
passwd $USER
10+
export TERRA_USER=terrau
11+
./root1.sh
1512
```
1613

17-
Then copy the SSH keys that the root user accepts (if any).
14+
Then copy the SSH keys that the root user accepts (if any) and enable the user to use `sudo` without entering a password.
1815

1916
```
20-
cp -r .ssh /home/$USER
21-
chown -R $USER:$USER /home/$USER/.ssh
22-
chmod 644 /home/$USER/.ssh/authorized_keys
17+
./root2.sh
2318
```
2419

25-
Enable the user to use sudo without entering a password.
26-
27-
```
28-
echo "$USER ALL=NOPASSWD: ALL" >> /etc/sudoers
29-
```
30-
31-
Recommended - change the default port and remove root SSH.
32-
33-
```
34-
# Port 8888
35-
# PermitRootLogin no
36-
# PasswordAuthentication no
37-
```
38-
39-
Then restart the server: `systemctl restart sshd `
20+
This script also makes changes to SSH default configurations and extends the resource limits.
4021

4122
Recommended - change the name of the machine to easily identify it.
4223

4324
sudo hostname {SERVER-NAME}
4425

45-
Extend the limits for the server by appending the following to /etc/security/limits.conf
46-
47-
```
48-
* soft nofile 65535
49-
* hard nofile 65535
50-
```
51-
5226
# start.sh
5327

5428
This script is to be run as a user in server. It downloads and sets up the software that is needed to get the validator running.

terra/root1.sh

100644100755
File mode changed.

terra/root2.sh

100644100755
Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
#!/bin/bash
22

3-
if [[ -z "${TERRA_USER}" ]]; then
3+
if [[ -z "${TERRA_USER}" ]]
4+
then
45
echo "ERROR: Environment variable 'TERRA_USER' must be defined first. E.g."
56
echo " export TERRA_USER=terrau"
67
exit
78
fi
89

9-
echo "> Copying SSH keys to new user account..."
10+
if [[ -d /home/root/.ssh ]]
11+
then
12+
echo "> Copying SSH keys to new user account..."
1013

11-
cp -r .ssh /home/$TERRA_USER
12-
chown -R $TERRA_USER:$TERRA_USER /home/$TERRA_USER/.ssh
13-
chmod 644 /home/$TERRA_USER/.ssh/authorized_keys
14+
cp -r .ssh /home/$TERRA_USER
15+
chown -R $TERRA_USER:$TERRA_USER /home/$TERRA_USER/.ssh
16+
chmod 644 /home/$TERRA_USER/.ssh/authorized_keys
1417

15-
echo " Done."
18+
echo " Done."
19+
fi
1620

1721
echo "> Enabling sudo without password..."
1822

@@ -27,3 +31,11 @@ echo "* hard nofile 65535" >> /etc/security/limits.co
2731

2832
echo " Done."
2933

34+
echo "> Changing default SSH port, password login, and root configurations..."
35+
36+
echo "Port 9560" >> /etc/ssh/sshd_config
37+
echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
38+
echo "PermitRootLogin no" >> /etc/ssh/sshd_config
39+
systemctl restart sshd
40+
41+
echo " Done."

0 commit comments

Comments
 (0)