- djm@cvs.openbsd.org 2010/01/13 01:40:16
[openssh-git.git] / regress / ssh2putty.sh
blob691db1690da2fd1bdcf2ad3ca6d8e11e411511b9
1 #!/bin/sh
2 # $OpenBSD: ssh2putty.sh,v 1.2 2009/10/06 23:51:49 dtucker Exp $
4 if test "x$1" = "x" -o "x$2" = "x" -o "x$3" = "x" ; then
5 echo "Usage: ssh2putty hostname port ssh-private-key"
6 exit 1
7 fi
9 HOST=$1
10 PORT=$2
11 KEYFILE=$3
13 # XXX - support DSA keys too
14 if grep "BEGIN RSA PRIVATE KEY" $KEYFILE >/dev/null 2>&1 ; then
16 else
17 echo "Unsupported private key format"
18 exit 1
21 public_exponent=`
22 openssl rsa -noout -text -in $KEYFILE | grep ^publicExponent |
23 sed 's/.*(//;s/).*//'
25 test $? -ne 0 && exit 1
27 modulus=`
28 openssl rsa -noout -modulus -in $KEYFILE | grep ^Modulus= |
29 sed 's/^Modulus=/0x/' | tr A-Z a-z
31 test $? -ne 0 && exit 1
33 echo "rsa2@$PORT:$HOST $public_exponent,$modulus"