Skip to content

Instantly share code, notes, and snippets.

@gocs
Last active October 28, 2022 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gocs/7547437933622e65237698aac23b6485 to your computer and use it in GitHub Desktop.
Save gocs/7547437933622e65237698aac23b6485 to your computer and use it in GitHub Desktop.
Linux setups after initial os boot

update os (DO THIS FIRST)

sudo apt update
sudo apt upgrade -y

enable password authentication for ssh

  • modify /etc/ssh/sshd_config
  • find the PasswordAuthentication line, then uncomment or set PasswordAuthentication to yes
...
-PasswordAuthentication no
+PasswordAuthentication yes
...

setup firewall

In a web application environment, user facing ports should only be ssh, http, and https.

sudo ufw enable
sudo ufw status # check if active
sudo ufw allow ssh # or 22
sudo ufw allow http # or 80
sudo ufw allow https # or 443
sudo ufw status # check if ssh, http, and https are allowed anywhere

create and use the user

please ask for assistance for the linux username

sudo adduser <username>
sudo passwd <username> # if password is never prompted
sudo usermod -aG sudo <username> # give user the sudoer's privilege
su <username>
  • restart ssh service
sudo service ssh restart

The following steps should be done using the newly created user

install nginx (optional)

sudo apt update
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
nginx -v

make sure the output is like this: nginx version: nginx.. otherwise ask for assistance

setup php7.4 (optional)

sudo apt update
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php -y
sudo apt update # get update from add-apt-repository and others
sudo apt install php7.4 -y
sudo apt install php7.4-{cli,common,curl,zip,gd,mysql,xml,mbstring,json,intl} -y
php -v

make sure the output is like this: PHP 7.4.. otherwise ask for assistance

install docker

sudo apt-get update
sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo usermod -aG docker $USER
sudo service docker start
sudo docker compose up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment