#!/bin/sh
# $Id: anonssh,v 1.6 2021/10/04 03:09:55 nanons Exp $
#
# Usage: anonssh <ssh args>
# This script generates a key pair, runs ssh(1), then deletes the keys
# To route traffic over Tor, see ssh/ssh_config

# Works with ssh, sftp, scp.  Change this variable to either one.
prog=ssh

set -e

# -P also overwrites the keys
trap 'rm -fP "$key" "$key.pub"' EXIT

key=$(mktemp -p ~/.ssh)

# 'y' confirms the prompt to overwrite the temp file
echo y | ssh-keygen -q -f "$key" -N '' -C '' > /dev/null

"$prog" -i "$key" "$@"
