/initial-ubuntu

Just trying to reduce effort when order a new server with fast script install initial Ubuntu server, docker, docker-compose, caddy, portainer, wireguard

Primary LanguageShell

This script will install:

Initial new fresh server using jasonheecs repo

Recommendation

  • Recommended linux distro: ubuntu 20.04 (tested)

  • id_rsa.pub - ssh-key in your local pc (here is id_rsa.pub) - copy and paste down the your id_rsa.pub somewhere or even here

## at your local pc
ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub ## !!IMPORTANT print PC public key OUT
ls -al ~/.ssh ## to organize keys -> check key
nano ~/.ssh/known_hosts ## In case you re-install server & remove all old ssh-key from the rebuilt server
nano ~/.ssh/authorized_keys ### copy 1 more public key to server
  • root-password of your server - from your provider

Getting Started

1 script to go (and some prompt input 😂)

apt-get update &&
apt-get install git &&
git clone https://github.com/jasonheecs/ubuntu-server-setup.git &&
bash ./ubuntu-server-setup/setup.sh

It will do apt update, install git, clone jasonheecs repo (Install new non-root user for a fresh server with ssh-key log in and disable root login). It will ask you (prompts):

  • Do you want to create a new non-root user (Recommended): Y
  • Enter the username of the new user account: your-account (not your-account, your real account)
  • Full name, room number, work phone, home phone, other,...: Just enter for all default anwser (6 enters)
  • Paste in the public SSH key for the new user: This is the important one, if pass the wrong key, you have to rebuild the server and re-do all the task again. Paste the id_rsa.pub we have prepared before
  • Enter the timezone for the server (Default is 'Asia/Singapore'): your-server-timezone (mine is Asia/Ho_Chi_Minh) Check List of time zones

Check if everything is good

SSH-key login: Open a new terminal Git Bash, try ssh your-remote-server-ip or ssh your-account@your-remote-server-ip

If you can log in without input password, you good and from now you should exit root user ssh session and using ssh user@your-server

My customized menu script to install:

Download script and run

git -C ~/initial-ubuntu pull || git clone https://github.com/hophamlam/initial-ubuntu.git ~/initial-ubuntu &&
cd initial-ubuntu &&
mv ./docker/.env.sample ./docker/.env &&
nano ./docker/.env &&
sh menu.sh

Re-run

bash ~/initial-ubuntu/menu.sh

initial-ubuntu/
├── caddy/
│   ├── Caddyfile
│   └── site/
│       └── .
├── wg/
│   ├── wg0.conf
│   └── wg0.json
├── docker-compose.yml
├── menu.sh
└── .env