sábado, 25 de julho de 2020

First server configuration

apt update -y && apt upgrade -y
apt install sudo

### Create user
export USERNAME='user'
export PASSWORD='userpassword'
useradd -m -p $(openssl passwd -1 ${PASSWORD}) -s /bin/bash -G sudo ${USERNAME}
echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

### SSH Config
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bkp
sed '/MaxAuthTries/d' /etc/ssh/sshd_config.bkp > /etc/ssh/sshd_config
echo "MaxAuthTries 3" >> /etc/ssh/sshd_config
grep "^MaxAuthTries" /etc/ssh/sshd_config

cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bkp
sed '/PermitRootLogin/d' /etc/ssh/sshd_config.bkp > /etc/ssh/sshd_config
echo "PermitRootLogin no" >> /etc/ssh/sshd_config
grep "^PermitRootLogin" /etc/ssh/sshd_config

/etc/init.d/ssh restart

### Install the Basics
apt install curl git net-tools build-essential tmux screen

Nenhum comentário:

Postar um comentário