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 Stringstatic Stringfingerprint(BigInteger publicExponent, BigInteger modulus) Create a fingerprint per the following specstatic StringfingerprintPrivateKey(String privateKeyPEM) static StringfingerprintPublicKey(String publicKeyOpenSSH) generate()return a "public" -> rsa public key, "private" -> its corresponding private keygenerate(KeyPairGenerator generator, SecureRandom rand) static KeyPairgenerateRsaKeyPair(KeyPairGenerator generator, SecureRandom rand) static booleanprivateKeyHasFingerprint(String privateKeyPEM, String fingerprint) static booleanprivateKeyHasFingerprint(RSAPrivateCrtKeySpec privateKey, String fingerprint) static booleanprivateKeyHasSha1(String privateKeyPEM, String sha1HexColonDelimited) static booleanprivateKeyHasSha1(RSAPrivateCrtKeySpec privateKey, String fingerprint) static booleanprivateKeyMatchesPublicKey(String privateKeyPEM, String publicKeyOpenSSH) static booleanprivateKeyMatchesPublicKey(RSAPrivateCrtKeySpec privateKey, RSAPublicKeySpec publicKey) static booleanpublicKeyHasFingerprint(String publicKeyOpenSSH, String fingerprint) static booleanpublicKeyHasFingerprint(RSAPublicKeySpec publicKey, String fingerprint) static RSAPublicKeySpecpublicKeySpecFromOpenSSH(com.google.common.io.ByteSource supplier) ReturnsRSAPublicKeySpecwhich was OpenSSH Base64 Encodedid_rsa.pubstatic RSAPublicKeySpecpublicKeySpecFromOpenSSH(String idRsaPub) Executeson the string which was OpenSSH Base64 Encodedinvalid reference
Pems#publicKeySpecFromOpenSSH(ByteSource)id_rsa.pubstatic Stringsha1(RSAPrivateCrtKeySpec privateKey) Create a SHA-1 digest of the DER encoded private key.static Stringsha1PrivateKey(String privateKeyPEM)
-
Constructor Details
-
SshKeys
public SshKeys()
-
-
Method Details
-
publicKeySpecFromOpenSSH
Executeson the string which was OpenSSH Base64 Encodedinvalid 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 ReturnsRSAPublicKeySpecwhich was OpenSSH Base64 Encodedid_rsa.pub- Parameters:
supplier- the input stream factory, formattedssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAB...- Returns:
- the
RSAPublicKeySpecwhich 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
-