Package org.kohsuke.putty
Class PuTTYKey
- java.lang.Object
-
- org.kohsuke.putty.PuTTYKey
-
public class PuTTYKey extends java.lang.Object
Interprets PuTTY's ".ppk" file.Notes
- The file appears to be a text file but it doesn't have the fixed encoding. So we just use the platform default encoding, which is what PuTTY seems to use. Fortunately, the important part is all ASCII, so this shouldn't really hurt the interpretation of the key.
Sample PuTTY file format
PuTTY-User-Key-File-2: ssh-rsa Encryption: none Comment: rsa-key-20080514 Public-Lines: 4 AAAAB3NzaC1yc2EAAAABJQAAAIEAiPVUpONjGeVrwgRPOqy3Ym6kF/f8bltnmjA2 BMdAtaOpiD8A2ooqtLS5zWYuc0xkW0ogoKvORN+RF4JI+uNUlkxWxnzJM9JLpnvA HrMoVFaQ0cgDMIHtE1Ob1cGAhlNInPCRnGNJpBNcJ/OJye3yt7WqHP4SPCCLb6nL nmBUrLM= Private-Lines: 8 AAAAgGtYgJzpktzyFjBIkSAmgeVdozVhgKmF6WsDMUID9HKwtU8cn83h6h7ug8qA hUWcvVxO201/vViTjWVz9ALph3uMnpJiuQaaNYIGztGJBRsBwmQW9738pUXcsUXZ 79KJP01oHn6Wkrgk26DIOsz04QOBI6C8RumBO4+F1WdfueM9AAAAQQDmA4hcK8Bx nVtEpcF310mKD3nsbJqARdw5NV9kCxPnEsmy7Sy1L4Ob/nTIrynbc3MA9HQVJkUz 7V0va5Pjm/T7AAAAQQCYbnG0UEekwk0LG1Hkxh1OrKMxCw2KWMN8ac3L0LVBg/Tk 8EnB2oT45GGeJaw7KzdoOMFZz0iXLsVLNUjNn2mpAAAAQQCN6SEfWqiNzyc/w5n/ lFVDHExfVUJp0wXv+kzZzylnw4fs00lC3k4PZDSsb+jYCMesnfJjhDgkUA0XPyo8 Emdk Private-MAC: 50c45751d18d74c00fca395deb7b7695e3ed6f77
- Author:
- Kohsuke Kawaguchi
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getAlgorithm()
Key type.static boolean
isPuTTYKeyFile(java.io.File ppkFile)
Checks if the given file is a PuTTY's ".ppk" file, by looking at the file contents.static boolean
isPuTTYKeyFile(java.io.InputStream in)
static boolean
isPuTTYKeyFile(java.io.Reader _reader)
java.lang.String
toOpenSSH()
Converts this key into OpenSSH format.void
toOpenSSH(java.io.File f)
Converts the key to OpenSSH format, then write it to a file.
-
-
-
Constructor Detail
-
PuTTYKey
public PuTTYKey(java.io.File ppkFile, java.lang.String passphrase) throws java.io.IOException
- Throws:
java.io.IOException
-
PuTTYKey
public PuTTYKey(java.io.InputStream in, java.lang.String passphrase) throws java.io.IOException
- Throws:
java.io.IOException
-
PuTTYKey
public PuTTYKey(java.io.Reader in, java.lang.String passphrase) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
getAlgorithm
public java.lang.String getAlgorithm()
Key type. Either "ssh-rsa" for RSA key, or "ssh-dss" for DSA key.
-
toOpenSSH
public java.lang.String toOpenSSH() throws java.io.IOException
Converts this key into OpenSSH format.- Returns:
- A multi-line string that can be written back to a file.
- Throws:
java.io.IOException
-
toOpenSSH
public void toOpenSSH(java.io.File f) throws java.io.IOException
Converts the key to OpenSSH format, then write it to a file.- Throws:
java.io.IOException
-
isPuTTYKeyFile
public static boolean isPuTTYKeyFile(java.io.File ppkFile) throws java.io.IOException
Checks if the given file is a PuTTY's ".ppk" file, by looking at the file contents.- Throws:
java.io.IOException
-
isPuTTYKeyFile
public static boolean isPuTTYKeyFile(java.io.InputStream in) throws java.io.IOException
- Throws:
java.io.IOException
-
isPuTTYKeyFile
public static boolean isPuTTYKeyFile(java.io.Reader _reader) throws java.io.IOException
- Throws:
java.io.IOException
-
-