Skip to content

Instantly share code, notes, and snippets.

@andyklimczak
Last active July 26, 2024 01:47
Show Gist options
  • Save andyklimczak/50880c8dfa336d009b255dc64bc0969d to your computer and use it in GitHub Desktop.
Save andyklimczak/50880c8dfa336d009b255dc64bc0969d to your computer and use it in GitHub Desktop.
New dokku setup stuff

ssh in (typically ubuntu digital ocean dokku marketplace image)

$ ssh host

Create user other than root to log in to with sudo and dokku groups

# adduser somename
# usermod -aG sudo somename
# usermod -aG dokku somename

Copy ssh key from local to server

$ ssh-copy-id -i ~/.ssh/mykey somename@host

Add to .ssh/config

Host servername
  HostName host
  User somename
  IdentityFile /home/someuser/.ssh/id_key
  IdentitiesOnly yes

ssh in as user using config and ssh key (shouldn't ask for password)

ssh servername

then exit root ssh

Upgrade system

sudo apt update
sudo apt dist-upgrade

Install dokku update

$ sudo apt install dokku-update
$ sudo dokku-update run

Then reboot

sudo reboot

Secure ssh (simple)

$ sudo vim /etc/ssh/sshd_config

Change:

PermitRootLogin no
PasswordAuthentication no

Uncomment/change:

PermitEmptyPasswords no
MaxAuthTries 3
X11Forwarding no 
AllowTcpForwarding no

Restart ssh

sudo systemctl restart ssh

then try to login as root, shouldn't work

Add swap (if memory low)

Helps with deploying faster if you don't need a lot of storage space

$ sudo fallocate -l 4G /swapfile
$ ls -lh /swapfile
$ sudo mkswap /swapfile
$ sudo swapon /swapfile
$ sudo cp /etc/fstab /etc/fstab.bak
$ echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Dokku stuff

$ echo 'PUB KEY' | sudo dokku ssh-keys:add somename

Done?

Should be good to create dokku apps now. Set git remote to dokku instance and push branch

git remote add dokku dokku@servername:appname // use servername from ~/.ssh/config setup
git push dokku master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment