Skip to content

Instantly share code, notes, and snippets.

@xykj61
Last active January 4, 2023 05:10
Show Gist options
  • Select an option

  • Save xykj61/087d0b81b5a2da454723a95ec0ad86c1 to your computer and use it in GitHub Desktop.

Select an option

Save xykj61/087d0b81b5a2da454723a95ec0ad86c1 to your computer and use it in GitHub Desktop.
ubuntu 20.04 lts cloud startup

start it up

initial server config ubuntu 20.04 lts

ufw allow OpenSSH
ufw enable
adduser keaton
usermod -aG sudo keaton
cp /etc/sudoers /etc/sudoers.bak
printf "#\n# keaton\n#\nKEATON ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
rsync --archive --chown=keaton:keaton ~/.ssh /home/keaton
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
sed -i 's/PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/sshd_config
service ssh reload
sudo apt update
sudo apt upgrade -y

screen basic config

screen basic config (stack overflow): https://unix.stackexchange.com/questions/114505/gnu-screen-status-bar-how-to-make-it-display-shell-session-names

vim ~/.screenrc :

autodetach on 
startup_message off 
hardstatus alwayslastline 
shelltitle 'zsh'

hardstatus string '%{gk}[%{wk}%?%-Lw%?%{=b kR}(%{W}%n*%f %t%?(%u)%?%{=b kR})%{= w}%?%+Lw%?%? %{g}][%{d}%l%{g}][ %{= w}%Y/%m/%d %0C:%s%a%{g} ]%{W}'

start screen sesh

screen -S web

install kakoune

sudo apt install -y kakoune

install zsh & oh-my-zsh

sudo apt install -y zsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

(Y, change default shell to zsh).

(just in case) :

sudo chsh -s $(which zsh)

clone zsh-autosuggestions and edit .zshrc:

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

https://gist.github.com/bitcoinv3/6a62cbd869ac8be1fb38eb12eed2d190

source ~/.zshrc

install mosh

sudo apt install -y mosh

install neovim and set it up

sudo apt install -y software-properties-common
sudo add-apt-repository -y ppa:neovim-ppa/stable
sudo apt update
sudo apt install -y python2 python2-dev python3-dev python3-pip python3-neovim
sudo apt install -y neovim
mkdir -p ~/.config/nvim
kak ~/.config/nvim/init.vim

(or scp it from local machine // :

https://gist.github.com/bitcoinv3/e70884c8dc646abfc56c201a53ec6948

)

urbit

sudo ufw allow http
sudo ufw allow https
mkdir ~/urbit
cd ~/urbit
curl -L https://urbit.org/install/linux64/latest | tar xzk --strip=1 && ./urbit
sudo cp ~/urbit/urbit /usr/local/bin
urbit
sudo apt install -y libcap2-bin
sudo setcap 'cap_net_bind_service=+ep' ~/urbit/urbit
sudo setcap 'cap_net_bind_service=+ep' $(which urbit)
sudo ufw allow 65535/tcp

(local) :

scp ~/Downloads/xxxxxx-xxxxxx-1.key keaton@xxx.xxx.x.x:~/urbit

(back to server) :

cd ~/urbit
./urbit -p 65535 -w xxxxxx-xxxxxx -k ./xxxxxx-xxxxxx-1.key

nginx

sudo apt update
sudo apt install -y nginx
sudo mkdir -p /var/www/XXXXXXXXX.com/html
sudo chown -R $USER:$USER /var/www/XXXXXXXXX.com/html
sudo chmod -R 755 /var/www/XXXXXXXXX.com
sudo kak /var/www/XXXXXXXXX.com/html/index.html

copy paste in vim (just to get started per the ^ tutorial) ::

<html>
<head>
    <title>Welcome to your_domain!</title>
</head>
<body>
    <h1>Success!  The your_domain server block is working!</h1>
</body>
</html>

continue ::

sudo kak /etc/nginx/sites-available/XXXXXXXXX.com

paste :

server {
        listen 80;
        listen [::]:80;

        root /var/www/XXXXXXXXX.com/html;
        index index.html index.htm index.nginx-debian.html;

        server_name XXXXXXXXX.com www.XXXXXXXXX.com;

        location / {
                try_files $uri $uri/ =404;
        }
}

continue again ::

sudo ln -s /etc/nginx/sites-available/XXXXXXXXX.com /etc/nginx/sites-enabled/

sudo kak /etc/nginx/nginx.conf

editor again :

# Find the server_names_hash_bucket_size directive and remove the # symbol to uncomment the line.

...
http {
    ...
    server_names_hash_bucket_size 64;        <------
    ...
}
...

# make sure there are no errors

sudo nginx -t
sudo systemctl restart nginx

test out that http://xxxxxxxxx.com works.


letsencrypt

https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-20-04

sudo apt install -y certbot python3-certbot-nginx
sudo ufw delete allow 'Nginx HTTP'
sudo certbot --nginx -d XXXXXXXXX.com -d www.XXXXXXXXX.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment