Initial server setup with Ubuntu 18.10
genkio opened this issue · 0 comments
genkio commented
Create new user
adduser joe
usermod -aG sudo joe
Start firewall
ufw allow OpenSSH
ufw allow new-ssh-port
ufw enable
ufw status
Set up SSH key authentication
mkdir -p ~/.ssh
echo public-key-string >> ~/.ssh/authorized_keys
chmod -R go= ~/.ssh
# after that, try access your server in your local client machine by:
ssh -i ~/.ssh/joe_id_rsa joe@server-ip -p new-ssh-port
Update ssh config
# /etc/ssh/sshd_config
Port 5657
PermitRootLogin no
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
Restart ssh service
sudo service sshd restart
Productivity booster
# verify mounted disk
sudo fdisk -l
# verify disk space
df -h
### create alias by editing ~/.zshrc
alias ssh_auto_signin="ssh joe@server-ip -p new-ssh-port"
# reload
source .zshrc
Install docker
sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt update
apt-cache policy docker-ce
sudo apt install docker-ce
sudo systemctl status docker
# executing the Docker command without sudo
sudo usermod -aG docker ${USER}
su - ${USER}
id -nG
docker run hello-world
Use tmux for session management
# start new named session:
tmux new -s [session name]
# attach to the first available session:
tmux a
# attach to a specific session by name:
tmux a -t [session name]
# detach from session:
ctrl+b d
# list sessions:
tmux ls
# kill named session:
tmux kill-session -t [name of session]
# split panes horizontally:
ctrl+b "
# split panes vertically:
ctrl+b %
# kill current pane:
ctrl+b x
# move to another pane:
ctrl+b [arrow key]
# kill tmux server, along with all sessions:
tmux kill-server