sshtmp.fish

 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    try
14        ssh-keygen -t ed25519 -f "$key_path" -N "" -C "sshtmp temporary key for $destination" >/dev/null
15        command ssh -i "$key_path" \
16            -o IdentitiesOnly=yes \
17            -o StrictHostKeyChecking=no \
18            -o UserKnownHostsFile=/dev/null \
19            $destination
20    finally
21        rm -rf "$tmp_dir"
22    end
23end