SSH Setup — Termux to VPS

One-liner command to install OpenSSH in Termux and connect to the VPS.

Command

pkg install -y openssh && { [ -f ~/.ssh/id_ed25519 ] && ssh -o StrictHostKeyChecking=accept-new pi@188.166.230.202 -t "cd /home/pi/vault && exec bash -l" || (ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N "" && cat ~/.ssh/id_ed25519.pub); }

What it does

  1. Installs OpenSSH package
  2. Checks for existing Ed25519 keypair
  3. If key exists: SSH directly to VPS and land in vault directory
  4. If no key: Generate new keypair and output public key (for manual copy to VPS ~/.ssh/authorized_keys)

Connection details

Parameter Value
User pi
Host 188.166.230.202
Working dir /home/pi/vault
Key type Ed25519

Related