diff options
Diffstat (limited to 'regress/ssh2putty.sh')
-rwxr-xr-x | regress/ssh2putty.sh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/regress/ssh2putty.sh b/regress/ssh2putty.sh new file mode 100755 index 000000000..82dd44787 --- /dev/null +++ b/regress/ssh2putty.sh | |||
@@ -0,0 +1,31 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | if test "x$1" = "x" -o "x$2" = "x" -o "x$3" = "x" ; then | ||
4 | echo "Usage: ssh2putty hostname port ssh-private-key" | ||
5 | exit 1 | ||
6 | fi | ||
7 | |||
8 | HOST=$1 | ||
9 | PORT=$2 | ||
10 | KEYFILE=$3 | ||
11 | |||
12 | # XXX - support DSA keys too | ||
13 | if ! grep -q "BEGIN RSA PRIVATE KEY" $KEYFILE ; then | ||
14 | echo "Unsupported private key format" | ||
15 | exit 1 | ||
16 | fi | ||
17 | |||
18 | public_exponent=` | ||
19 | openssl rsa -noout -text -in $KEYFILE | grep ^publicExponent | | ||
20 | sed 's/.*(//;s/).*//' | ||
21 | ` | ||
22 | test $? -ne 0 && exit 1 | ||
23 | |||
24 | modulus=` | ||
25 | openssl rsa -noout -modulus -in $KEYFILE | grep ^Modulus= | | ||
26 | sed 's/^Modulus=/0x/' | tr A-Z a-z | ||
27 | ` | ||
28 | test $? -ne 0 && exit 1 | ||
29 | |||
30 | echo "rsa2@$PORT:$HOST $public_exponent,$modulus" | ||
31 | |||