Skip to content

SSH keys

Use VM-local keys. Do not copy host private keys into the guest. Add only the public key to your Git host. The comment identifies the VM and purpose.

Terminal window
sudo -u "$DVM_USER" -H bash -lc '
set -Eeuo pipefail
install -d -m 700 ~/.ssh
test -f ~/.ssh/id_ed25519 ||
ssh-keygen -t ed25519 -N "" -C "${DVM_NAME}-dvm-git-deploy" -f ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pub
'

Separate deploy and signing keys:

Terminal window
sudo -u "$DVM_USER" -H bash -lc '
set -Eeuo pipefail
install -d -m 700 ~/.ssh
for kind in deploy signing; do
key="$HOME/.ssh/id_ed25519_$kind"
test -f "$key" ||
ssh-keygen -q -t ed25519 -N "" -C "${DVM_NAME}-dvm-git-$kind" -f "$key"
done
'

After the key is added to GitHub/GitLab:

Terminal window
dvm sh app
git clone [email protected]:me/app.git ~/code/app
cd ~/code/app

Built and maintained by eshlox.