mirror of
git://anongit.mindrot.org/openssh.git
synced 2025-01-03 08:12:05 +00:00
07660b3c99
allows overriding if necessary (eg in -portable where we're testing against a specific version of OpenSSL). OpenBSD-Regress-ID: 491f39cae9e762c71aa4bf045803d077139815c5
35 lines
699 B
Bash
Executable File
35 lines
699 B
Bash
Executable File
#!/bin/sh
|
|
# $OpenBSD: ssh2putty.sh,v 1.6 2021/05/24 10:25:18 dtucker Exp $
|
|
|
|
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
|
|
|
|
# XXX - support DSA keys too
|
|
if grep "BEGIN RSA PRIVATE KEY" $KEYFILE >/dev/null 2>&1 ; then
|
|
:
|
|
else
|
|
echo "Unsupported private key format"
|
|
exit 1
|
|
fi
|
|
|
|
public_exponent=`
|
|
$OPENSSL rsa -noout -text -in $KEYFILE | grep ^publicExponent |
|
|
sed 's/.*(//;s/).*//'
|
|
`
|
|
test $? -ne 0 && exit 1
|
|
|
|
modulus=`
|
|
$OPENSSL rsa -noout -modulus -in $KEYFILE | grep ^Modulus= |
|
|
sed 's/^Modulus=/0x/' | tr A-Z a-z
|
|
`
|
|
test $? -ne 0 && exit 1
|
|
|
|
echo "rsa2@$PORT:$HOST $public_exponent,$modulus"
|
|
|