2008-03-12 13:17:00 +00:00
|
|
|
#!/bin/sh
|
2021-07-25 12:13:03 +00:00
|
|
|
# $OpenBSD: ssh2putty.sh,v 1.9 2021/07/25 12:13:03 dtucker Exp $
|
2008-03-12 13:17:00 +00:00
|
|
|
|
|
|
|
if test "x$1" = "x" -o "x$2" = "x" -o "x$3" = "x" ; then
|
|
|
|
echo "Usage: ssh2putty hostname port ssh-private-key"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
HOST=$1
|
|
|
|
PORT=$2
|
|
|
|
KEYFILE=$3
|
|
|
|
|
2021-07-25 12:13:03 +00:00
|
|
|
OPENSSL_BIN="${OPENSSL_BIN:-openssl}"
|
2021-06-01 23:56:20 +00:00
|
|
|
|
2008-03-12 13:17:00 +00:00
|
|
|
# XXX - support DSA keys too
|
2008-03-14 01:21:06 +00:00
|
|
|
if grep "BEGIN RSA PRIVATE KEY" $KEYFILE >/dev/null 2>&1 ; then
|
|
|
|
:
|
|
|
|
else
|
2008-03-12 13:17:00 +00:00
|
|
|
echo "Unsupported private key format"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
public_exponent=`
|
2021-07-25 12:13:03 +00:00
|
|
|
$OPENSSL_BIN rsa -noout -text -in $KEYFILE | grep ^publicExponent |
|
2008-03-12 13:17:00 +00:00
|
|
|
sed 's/.*(//;s/).*//'
|
|
|
|
`
|
|
|
|
test $? -ne 0 && exit 1
|
|
|
|
|
|
|
|
modulus=`
|
2021-07-25 12:13:03 +00:00
|
|
|
$OPENSSL_BIN rsa -noout -modulus -in $KEYFILE | grep ^Modulus= |
|
2008-03-12 13:17:00 +00:00
|
|
|
sed 's/^Modulus=/0x/' | tr A-Z a-z
|
|
|
|
`
|
|
|
|
test $? -ne 0 && exit 1
|
|
|
|
|
|
|
|
echo "rsa2@$PORT:$HOST $public_exponent,$modulus"
|
|
|
|
|