]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - crypto/openssh/regress/ssh2putty.sh
ssh: update FREEBSD-upgrade instructions
[FreeBSD/FreeBSD.git] / crypto / openssh / regress / ssh2putty.sh
1 #!/bin/sh
2 #       $OpenBSD: ssh2putty.sh,v 1.9 2021/07/25 12:13:03 dtucker Exp $
3
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
8
9 HOST=$1
10 PORT=$2
11 KEYFILE=$3
12
13 OPENSSL_BIN="${OPENSSL_BIN:-openssl}"
14
15 # XXX - support DSA keys too
16 if grep "BEGIN RSA PRIVATE KEY" $KEYFILE >/dev/null 2>&1 ; then
17         :
18 else
19         echo "Unsupported private key format"
20         exit 1
21 fi
22
23 public_exponent=`
24         $OPENSSL_BIN rsa -noout -text -in $KEYFILE | grep ^publicExponent |
25         sed 's/.*(//;s/).*//'
26 `
27 test $? -ne 0 && exit 1
28
29 modulus=`
30         $OPENSSL_BIN rsa -noout -modulus -in $KEYFILE | grep ^Modulus= |
31         sed 's/^Modulus=/0x/' | tr A-Z a-z
32 `
33 test $? -ne 0 && exit 1
34
35 echo "rsa2@$PORT:$HOST $public_exponent,$modulus"
36