function sshtmp --description "Connect to an SSH host using a temporary, one-time key" if test (count $argv) -eq 0 echo "Usage: sshtmp [user@]hostname" echo "Example: sshtmp sshtron.zachlatta.com" return 1 end set -l destination $argv[1] set -l tmp_dir (mktemp -d) set -l key_path "$tmp_dir/id_ed25519" try ssh-keygen -t ed25519 -f "$key_path" -N "" -C "sshtmp temporary key for $destination" >/dev/null command ssh -i "$key_path" \ -o IdentitiesOnly=yes \ -o StrictHostKeyChecking=no \ -o UserKnownHostsFile=/dev/null \ $destination finally rm -rf "$tmp_dir" end end