Package org.jclouds.ssh
Class SshKeys
java.lang.Object
org.jclouds.ssh.SshKeys
Utilities for ssh key pairs
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
static String
fingerprint
(BigInteger publicExponent, BigInteger modulus) Create a fingerprint per the following specstatic String
fingerprintPrivateKey
(String privateKeyPEM) static String
fingerprintPublicKey
(String publicKeyOpenSSH) generate()
return a "public" -> rsa public key, "private" -> its corresponding private keygenerate
(KeyPairGenerator generator, SecureRandom rand) static KeyPair
generateRsaKeyPair
(KeyPairGenerator generator, SecureRandom rand) static boolean
privateKeyHasFingerprint
(String privateKeyPEM, String fingerprint) static boolean
privateKeyHasFingerprint
(RSAPrivateCrtKeySpec privateKey, String fingerprint) static boolean
privateKeyHasSha1
(String privateKeyPEM, String sha1HexColonDelimited) static boolean
privateKeyHasSha1
(RSAPrivateCrtKeySpec privateKey, String fingerprint) static boolean
privateKeyMatchesPublicKey
(String privateKeyPEM, String publicKeyOpenSSH) static boolean
privateKeyMatchesPublicKey
(RSAPrivateCrtKeySpec privateKey, RSAPublicKeySpec publicKey) static boolean
publicKeyHasFingerprint
(String publicKeyOpenSSH, String fingerprint) static boolean
publicKeyHasFingerprint
(RSAPublicKeySpec publicKey, String fingerprint) static RSAPublicKeySpec
publicKeySpecFromOpenSSH
(com.google.common.io.ByteSource supplier) ReturnsRSAPublicKeySpec
which was OpenSSH Base64 Encodedid_rsa.pub
static RSAPublicKeySpec
publicKeySpecFromOpenSSH
(String idRsaPub) Executesinvalid reference
Pems#publicKeySpecFromOpenSSH(ByteSource)
id_rsa.pub
static String
sha1
(RSAPrivateCrtKeySpec privateKey) Create a SHA-1 digest of the DER encoded private key.static String
sha1PrivateKey
(String privateKeyPEM)
-
Constructor Details
-
SshKeys
public SshKeys()
-
-
Method Details
-
publicKeySpecFromOpenSSH
Executesinvalid reference
Pems#publicKeySpecFromOpenSSH(ByteSource)
id_rsa.pub
- Parameters:
idRsaPub
- formattedssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAB...
- See Also:
-
publicKeySpecFromOpenSSH
public static RSAPublicKeySpec publicKeySpecFromOpenSSH(com.google.common.io.ByteSource supplier) throws IOException ReturnsRSAPublicKeySpec
which was OpenSSH Base64 Encodedid_rsa.pub
- Parameters:
supplier
- the input stream factory, formattedssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAB...
- Returns:
- the
RSAPublicKeySpec
which was OpenSSH Base64 Encodedid_rsa.pub
- Throws:
IOException
- if an I/O error occurs
-
generateRsaKeyPair
- Parameters:
generator
- to generate RSA key pairsrand
- for initializinggenerator
- Returns:
- new 2048 bit keyPair
- See Also:
-
generate
return a "public" -> rsa public key, "private" -> its corresponding private key -
generate
-
encodeAsOpenSSH
-
privateKeyMatchesPublicKey
- Parameters:
privateKeyPEM
- RSA private key in PEM formatpublicKeyOpenSSH
- RSA public key in OpenSSH format- Returns:
- true if the keypairs match
-
privateKeyMatchesPublicKey
public static boolean privateKeyMatchesPublicKey(RSAPrivateCrtKeySpec privateKey, RSAPublicKeySpec publicKey) - Returns:
- true if the keypairs match
-
privateKeyHasFingerprint
- Returns:
- true if the keypair has the same fingerprint as supplied
-
privateKeyHasFingerprint
- Parameters:
privateKeyPEM
- RSA private key in PEM formatfingerprint
- ex.2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9
- Returns:
- true if the keypair has the same fingerprint as supplied
-
fingerprintPrivateKey
- Parameters:
privateKeyPEM
- RSA private key in PEM format- Returns:
- fingerprint ex.
2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9
-
fingerprintPublicKey
- Parameters:
publicKeyOpenSSH
- RSA public key in OpenSSH format- Returns:
- fingerprint ex.
2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9
-
privateKeyHasSha1
- Returns:
- true if the keypair has the same SHA1 fingerprint as supplied
-
privateKeyHasSha1
- Parameters:
privateKeyPEM
- RSA private key in PEM formatsha1HexColonDelimited
- ex.2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9
- Returns:
- true if the keypair has the same fingerprint as supplied
-
sha1PrivateKey
- Parameters:
privateKeyPEM
- RSA private key in PEM format- Returns:
- sha1HexColonDelimited ex.
2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9
-
sha1
Create a SHA-1 digest of the DER encoded private key.- Parameters:
publicExponent
-modulus
-- Returns:
- hex sha1HexColonDelimited ex.
2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9
-
publicKeyHasFingerprint
- Returns:
- true if the keypair has the same fingerprint as supplied
-
publicKeyHasFingerprint
- Parameters:
publicKeyOpenSSH
- RSA public key in OpenSSH formatfingerprint
- ex.2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9
- Returns:
- true if the keypair has the same fingerprint as supplied
-
fingerprint
Create a fingerprint per the following spec- Parameters:
publicExponent
-modulus
-- Returns:
- hex fingerprint ex.
2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9
-