1function sshtmp --description "Connect to an SSH host using a temporary, one-time key"
2 if test (count $argv) -eq 0
3 echo "Usage: sshtmp [user@]hostname"
4 echo "Example: sshtmp sshtron.zachlatta.com"
5 return 1
6 end
7
8 set -l destination $argv[1]
9
10 set -l tmp_dir (mktemp -d)
11 set -l key_path "$tmp_dir/id_ed25519"
12
13 ssh-keygen -t ed25519 -f "$key_path" -N "" -C "sshtmp temporary key for $destination" >/dev/null
14 command ssh -i "$key_path" \
15 -o IdentitiesOnly=yes \
16 -o StrictHostKeyChecking=no \
17 -o UserKnownHostsFile=/dev/null \
18 $destination
19 rm -rf "$tmp_dir"
20end