[jira] [Commented] (SSHD-984) Utility method to export KeyPair in OpenSSH format

2020-05-03 Thread Thomas Wolf (Jira)


[ 
https://issues.apache.org/jira/browse/SSHD-984?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17098473#comment-17098473
 ] 

Thomas Wolf commented on SSHD-984:
--

All right, here's the PR for writing OpenSSH style key files: 
https://github.com/apache/mina-sshd/pull/128

> Utility method to export KeyPair in OpenSSH format
> --
>
> Key: SSHD-984
> URL: https://issues.apache.org/jira/browse/SSHD-984
> Project: MINA SSHD
>  Issue Type: New Feature
>Affects Versions: 2.4.0
>Reporter: David Ostrovsky
>Priority: Minor
> Attachments: sshd_key_writing.zip
>
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> There are ongoing efforts in Gerrit Code Review and JGit projects to remove 
> dependency on JSch library: [1], [2]. Instead, MINA SSSD should be used on 
> both: client and server sides.
> One difficulty we are facing is the fact the MINA SSHD currently doesn't 
> provide any means to export generated KeyPair in OpenSSH format.
> Thomas Wolf added recently the ability to read encrypted OpenSSH private keys 
> in context of SSHD-708.
> With JSch this code would do the job:
> {code:java}
>   public static com.jcraft.jsch.KeyPair genSshKey() throws JSchException {
> JSch jsch = new JSch();
> return KeyPair.genKeyPair(jsch, KeyPair.ECDSA, 256);
>   }
>   public static String publicKey(com.jcraft.jsch.KeyPair sshKey, @Nullable 
> String comment)
>   throws UnsupportedEncodingException {
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> sshKey.writePublicKey(out, comment);
> return out.toString(US_ASCII.name()).trim();
>   }
>   public static byte[] privateKey(com.jcraft.jsch.KeyPair keyPair) {
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> keyPair.writePrivateKey(out);
> return out.toByteArray();
>   }
> {code}
> [1] [https://bugs.eclipse.org/bugs/show_bug.cgi?id=540727]
>  [2] [https://bugs.chromium.org/p/gerrit/issues/detail?id=12599]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org



[jira] [Commented] (SSHD-984) Utility method to export KeyPair in OpenSSH format

2020-04-30 Thread Lyor Goldstein (Jira)


[ 
https://issues.apache.org/jira/browse/SSHD-984?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17096255#comment-17096255
 ] 

Lyor Goldstein commented on SSHD-984:
-

{quote}
I tried to extend that prototype for better PEM writing (including encryption), 
but I think I don't quite understand how this should be done, or there are 
things missing in sshd.
{quote}
I don't think you should try to extend an existing prototype but rather 
invent/establish a new one. If  I were to suggest something it would a 
counterpoint to {{KeyPairResourceLoader}} - e.g., {{KeyPairResourceWriter}}.

{quote}
I don't see where and how I'd specify that I'd want to use 
PBKDF2WithHMAC-SHA1AndAES256-CBC for a passphrase-protected key to be written 
as a PKCS#8 PEM.
{quote}
Since you are establishing an entirely new hierarchy, do whatever seems right 
at the moment - try to make it as generic as possible, but don't fret about it 
too much. I am perfectly content with having some initial "rough" code that we 
will  polish as we encounter new requests to modify it. If  you really want to 
emphasize that it is experimental try defining it in the {{sshd-contrib}} 
module - if it only "consumes" other code and not needed by the other modules.


> Utility method to export KeyPair in OpenSSH format
> --
>
> Key: SSHD-984
> URL: https://issues.apache.org/jira/browse/SSHD-984
> Project: MINA SSHD
>  Issue Type: New Feature
>Affects Versions: 2.4.0
>Reporter: David Ostrovsky
>Priority: Minor
> Attachments: sshd_key_writing.zip
>
>
> There are ongoing efforts in Gerrit Code Review and JGit projects to remove 
> dependency on JSch library: [1], [2]. Instead, MINA SSSD should be used on 
> both: client and server sides.
> One difficulty we are facing is the fact the MINA SSHD currently doesn't 
> provide any means to export generated KeyPair in OpenSSH format.
> Thomas Wolf added recently the ability to read encrypted OpenSSH private keys 
> in context of SSHD-708.
> With JSch this code would do the job:
> {code:java}
>   public static com.jcraft.jsch.KeyPair genSshKey() throws JSchException {
> JSch jsch = new JSch();
> return KeyPair.genKeyPair(jsch, KeyPair.ECDSA, 256);
>   }
>   public static String publicKey(com.jcraft.jsch.KeyPair sshKey, @Nullable 
> String comment)
>   throws UnsupportedEncodingException {
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> sshKey.writePublicKey(out, comment);
> return out.toString(US_ASCII.name()).trim();
>   }
>   public static byte[] privateKey(com.jcraft.jsch.KeyPair keyPair) {
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> keyPair.writePrivateKey(out);
> return out.toByteArray();
>   }
> {code}
> [1] [https://bugs.eclipse.org/bugs/show_bug.cgi?id=540727]
>  [2] [https://bugs.chromium.org/p/gerrit/issues/detail?id=12599]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org



[jira] [Commented] (SSHD-984) Utility method to export KeyPair in OpenSSH format

2020-04-29 Thread Thomas Wolf (Jira)


[ 
https://issues.apache.org/jira/browse/SSHD-984?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17095461#comment-17095461
 ] 

Thomas Wolf commented on SSHD-984:
--

I tried to extend that prototype for better PEM writing (including encryption), 
but I think I don't quite understand how this should be done, or there are 
things missing in sshd. For instance, I don't see where and how I'd specify 
that I'd want to use PBKDF2WithHMAC-SHA1AndAES256-CBC for a 
passphrase-protected key to be written as a PKCS#8 PEM. So the PEM part of the 
prototype is really only a very rough sketch, and perhaps writing encrypted 
PEMs might indeed need Bouncy Castle.

The OpenSSH bcrypt format writing appears to work fine, though. (Tried only 
with AES.)

> Utility method to export KeyPair in OpenSSH format
> --
>
> Key: SSHD-984
> URL: https://issues.apache.org/jira/browse/SSHD-984
> Project: MINA SSHD
>  Issue Type: New Feature
>Affects Versions: 2.4.0
>Reporter: David Ostrovsky
>Priority: Minor
> Attachments: sshd_key_writing.zip
>
>
> There are ongoing efforts in Gerrit Code Review and JGit projects to remove 
> dependency on JSch library: [1], [2]. Instead, MINA SSSD should be used on 
> both: client and server sides.
> One difficulty we are facing is the fact the MINA SSHD currently doesn't 
> provide any means to export generated KeyPair in OpenSSH format.
> Thomas Wolf added recently the ability to read encrypted OpenSSH private keys 
> in context of SSHD-708.
> With JSch this code would do the job:
> {code:java}
>   public static com.jcraft.jsch.KeyPair genSshKey() throws JSchException {
> JSch jsch = new JSch();
> return KeyPair.genKeyPair(jsch, KeyPair.ECDSA, 256);
>   }
>   public static String publicKey(com.jcraft.jsch.KeyPair sshKey, @Nullable 
> String comment)
>   throws UnsupportedEncodingException {
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> sshKey.writePublicKey(out, comment);
> return out.toString(US_ASCII.name()).trim();
>   }
>   public static byte[] privateKey(com.jcraft.jsch.KeyPair keyPair) {
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> keyPair.writePrivateKey(out);
> return out.toByteArray();
>   }
> {code}
> [1] [https://bugs.eclipse.org/bugs/show_bug.cgi?id=540727]
>  [2] [https://bugs.chromium.org/p/gerrit/issues/detail?id=12599]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org



[jira] [Commented] (SSHD-984) Utility method to export KeyPair in OpenSSH format

2020-04-28 Thread Thomas Wolf (Jira)


[ 
https://issues.apache.org/jira/browse/SSHD-984?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17094609#comment-17094609
 ] 

Thomas Wolf commented on SSHD-984:
--

Attachment done. Enjoy!

> Utility method to export KeyPair in OpenSSH format
> --
>
> Key: SSHD-984
> URL: https://issues.apache.org/jira/browse/SSHD-984
> Project: MINA SSHD
>  Issue Type: New Feature
>Affects Versions: 2.4.0
>Reporter: David Ostrovsky
>Priority: Minor
> Attachments: sshd_key_writing.zip
>
>
> There are ongoing efforts in Gerrit Code Review and JGit projects to remove 
> dependency on JSch library: [1], [2]. Instead, MINA SSSD should be used on 
> both: client and server sides.
> One difficulty we are facing is the fact the MINA SSHD currently doesn't 
> provide any means to export generated KeyPair in OpenSSH format.
> Thomas Wolf added recently the ability to read encrypted OpenSSH private keys 
> in context of SSHD-708.
> With JSch this code would do the job:
> {code:java}
>   public static com.jcraft.jsch.KeyPair genSshKey() throws JSchException {
> JSch jsch = new JSch();
> return KeyPair.genKeyPair(jsch, KeyPair.ECDSA, 256);
>   }
>   public static String publicKey(com.jcraft.jsch.KeyPair sshKey, @Nullable 
> String comment)
>   throws UnsupportedEncodingException {
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> sshKey.writePublicKey(out, comment);
> return out.toString(US_ASCII.name()).trim();
>   }
>   public static byte[] privateKey(com.jcraft.jsch.KeyPair keyPair) {
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> keyPair.writePrivateKey(out);
> return out.toByteArray();
>   }
> {code}
> [1] [https://bugs.eclipse.org/bugs/show_bug.cgi?id=540727]
>  [2] [https://bugs.chromium.org/p/gerrit/issues/detail?id=12599]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org



[jira] [Commented] (SSHD-984) Utility method to export KeyPair in OpenSSH format

2020-04-28 Thread Lyor Goldstein (Jira)


[ 
https://issues.apache.org/jira/browse/SSHD-984?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17094592#comment-17094592
 ] 

Lyor Goldstein commented on SSHD-984:
-

Then attach the ZIP and I will see if I can find a home for it in the SSHD tree 
- then suggest it to you so we can have a PR over which we can discuss the 
code. Alternatively, I am OK with placing the code under the 
{{org.apache.sshd.common.config.keys.loader.openssh}} package for now and then 
re-factor it as needed.

> Utility method to export KeyPair in OpenSSH format
> --
>
> Key: SSHD-984
> URL: https://issues.apache.org/jira/browse/SSHD-984
> Project: MINA SSHD
>  Issue Type: New Feature
>Affects Versions: 2.4.0
>Reporter: David Ostrovsky
>Priority: Minor
>
> There are ongoing efforts in Gerrit Code Review and JGit projects to remove 
> dependency on JSch library: [1], [2]. Instead, MINA SSSD should be used on 
> both: client and server sides.
> One difficulty we are facing is the fact the MINA SSHD currently doesn't 
> provide any means to export generated KeyPair in OpenSSH format.
> Thomas Wolf added recently the ability to read encrypted OpenSSH private keys 
> in context of SSHD-708.
> With JSch this code would do the job:
> {code:java}
>   public static com.jcraft.jsch.KeyPair genSshKey() throws JSchException {
> JSch jsch = new JSch();
> return KeyPair.genKeyPair(jsch, KeyPair.ECDSA, 256);
>   }
>   public static String publicKey(com.jcraft.jsch.KeyPair sshKey, @Nullable 
> String comment)
>   throws UnsupportedEncodingException {
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> sshKey.writePublicKey(out, comment);
> return out.toString(US_ASCII.name()).trim();
>   }
>   public static byte[] privateKey(com.jcraft.jsch.KeyPair keyPair) {
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> keyPair.writePrivateKey(out);
> return out.toByteArray();
>   }
> {code}
> [1] [https://bugs.eclipse.org/bugs/show_bug.cgi?id=540727]
>  [2] [https://bugs.chromium.org/p/gerrit/issues/detail?id=12599]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org



[jira] [Commented] (SSHD-984) Utility method to export KeyPair in OpenSSH format

2020-04-28 Thread Thomas Wolf (Jira)


[ 
https://issues.apache.org/jira/browse/SSHD-984?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17094589#comment-17094589
 ] 

Thomas Wolf commented on SSHD-984:
--

Well, a PR would be much more work. AT least I'd have to give this prototype 
code a home in the sshd source tree. Right now it's outside.

> Utility method to export KeyPair in OpenSSH format
> --
>
> Key: SSHD-984
> URL: https://issues.apache.org/jira/browse/SSHD-984
> Project: MINA SSHD
>  Issue Type: New Feature
>Affects Versions: 2.4.0
>Reporter: David Ostrovsky
>Priority: Minor
>
> There are ongoing efforts in Gerrit Code Review and JGit projects to remove 
> dependency on JSch library: [1], [2]. Instead, MINA SSSD should be used on 
> both: client and server sides.
> One difficulty we are facing is the fact the MINA SSHD currently doesn't 
> provide any means to export generated KeyPair in OpenSSH format.
> Thomas Wolf added recently the ability to read encrypted OpenSSH private keys 
> in context of SSHD-708.
> With JSch this code would do the job:
> {code:java}
>   public static com.jcraft.jsch.KeyPair genSshKey() throws JSchException {
> JSch jsch = new JSch();
> return KeyPair.genKeyPair(jsch, KeyPair.ECDSA, 256);
>   }
>   public static String publicKey(com.jcraft.jsch.KeyPair sshKey, @Nullable 
> String comment)
>   throws UnsupportedEncodingException {
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> sshKey.writePublicKey(out, comment);
> return out.toString(US_ASCII.name()).trim();
>   }
>   public static byte[] privateKey(com.jcraft.jsch.KeyPair keyPair) {
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> keyPair.writePrivateKey(out);
> return out.toByteArray();
>   }
> {code}
> [1] [https://bugs.eclipse.org/bugs/show_bug.cgi?id=540727]
>  [2] [https://bugs.chromium.org/p/gerrit/issues/detail?id=12599]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org



[jira] [Commented] (SSHD-984) Utility method to export KeyPair in OpenSSH format

2020-04-28 Thread Lyor Goldstein (Jira)


[ 
https://issues.apache.org/jira/browse/SSHD-984?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17094579#comment-17094579
 ] 

Lyor Goldstein commented on SSHD-984:
-

{quote}
I have whipped up a fairly complete prototype including a minimal test for 
doing this (both writing PKCS#8 PEM files and the modern OpenSSH files with 
bcrypt KDF), but it's not in a state that it could be integrated easily into 
sshd.

I could provide you that code; shall I attach a zip here?
{quote}
Can you open up a PR (even though "not in a state that it could be integrated 
easily into sshd.") ? I  find it easier to review code in that format - not to 
mention the fact that we can discuss it as it progresses.

> Utility method to export KeyPair in OpenSSH format
> --
>
> Key: SSHD-984
> URL: https://issues.apache.org/jira/browse/SSHD-984
> Project: MINA SSHD
>  Issue Type: New Feature
>Affects Versions: 2.4.0
>Reporter: David Ostrovsky
>Priority: Minor
>
> There are ongoing efforts in Gerrit Code Review and JGit projects to remove 
> dependency on JSch library: [1], [2]. Instead, MINA SSSD should be used on 
> both: client and server sides.
> One difficulty we are facing is the fact the MINA SSHD currently doesn't 
> provide any means to export generated KeyPair in OpenSSH format.
> Thomas Wolf added recently the ability to read encrypted OpenSSH private keys 
> in context of SSHD-708.
> With JSch this code would do the job:
> {code:java}
>   public static com.jcraft.jsch.KeyPair genSshKey() throws JSchException {
> JSch jsch = new JSch();
> return KeyPair.genKeyPair(jsch, KeyPair.ECDSA, 256);
>   }
>   public static String publicKey(com.jcraft.jsch.KeyPair sshKey, @Nullable 
> String comment)
>   throws UnsupportedEncodingException {
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> sshKey.writePublicKey(out, comment);
> return out.toString(US_ASCII.name()).trim();
>   }
>   public static byte[] privateKey(com.jcraft.jsch.KeyPair keyPair) {
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> keyPair.writePrivateKey(out);
> return out.toByteArray();
>   }
> {code}
> [1] [https://bugs.eclipse.org/bugs/show_bug.cgi?id=540727]
>  [2] [https://bugs.chromium.org/p/gerrit/issues/detail?id=12599]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org



[jira] [Commented] (SSHD-984) Utility method to export KeyPair in OpenSSH format

2020-04-28 Thread Thomas Wolf (Jira)


[ 
https://issues.apache.org/jira/browse/SSHD-984?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17094577#comment-17094577
 ] 

Thomas Wolf commented on SSHD-984:
--

Lyor, BouncyCastle is not needed for this, and AFAIK has no support for writing 
the modern OpenSSH format anyway.

I have whipped up a fairly complete prototype including a minimal test for 
doing this (both writing PKCS#8 PEM files and the modern OpenSSH files with 
bcrypt KDF), but it's not in a state that it could be integrated easily into 
sshd.

I could provide you that code; shall I attach a zip here?

> Utility method to export KeyPair in OpenSSH format
> --
>
> Key: SSHD-984
> URL: https://issues.apache.org/jira/browse/SSHD-984
> Project: MINA SSHD
>  Issue Type: New Feature
>Affects Versions: 2.4.0
>Reporter: David Ostrovsky
>Priority: Minor
>
> There are ongoing efforts in Gerrit Code Review and JGit projects to remove 
> dependency on JSch library: [1], [2]. Instead, MINA SSSD should be used on 
> both: client and server sides.
> One difficulty we are facing is the fact the MINA SSHD currently doesn't 
> provide any means to export generated KeyPair in OpenSSH format.
> Thomas Wolf added recently the ability to read encrypted OpenSSH private keys 
> in context of SSHD-708.
> With JSch this code would do the job:
> {code:java}
>   public static com.jcraft.jsch.KeyPair genSshKey() throws JSchException {
> JSch jsch = new JSch();
> return KeyPair.genKeyPair(jsch, KeyPair.ECDSA, 256);
>   }
>   public static String publicKey(com.jcraft.jsch.KeyPair sshKey, @Nullable 
> String comment)
>   throws UnsupportedEncodingException {
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> sshKey.writePublicKey(out, comment);
> return out.toString(US_ASCII.name()).trim();
>   }
>   public static byte[] privateKey(com.jcraft.jsch.KeyPair keyPair) {
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> keyPair.writePrivateKey(out);
> return out.toByteArray();
>   }
> {code}
> [1] [https://bugs.eclipse.org/bugs/show_bug.cgi?id=540727]
>  [2] [https://bugs.chromium.org/p/gerrit/issues/detail?id=12599]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org



[jira] [Commented] (SSHD-984) Utility method to export KeyPair in OpenSSH format

2020-04-28 Thread Lyor Goldstein (Jira)


[ 
https://issues.apache.org/jira/browse/SSHD-984?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17094564#comment-17094564
 ] 

Lyor Goldstein commented on SSHD-984:
-

Seems like a valid request - until now our policy was that key files are 
generated by external tools. I will look into the possibility of using 
_Bouncycastle_ if possible. If so, it still trades one dependency (_jsch_) with 
another (_bouncycastle_) though I guess it still better than having both...

> Utility method to export KeyPair in OpenSSH format
> --
>
> Key: SSHD-984
> URL: https://issues.apache.org/jira/browse/SSHD-984
> Project: MINA SSHD
>  Issue Type: New Feature
>Affects Versions: 2.4.0
>Reporter: David Ostrovsky
>Priority: Minor
>
> There are ongoing efforts in Gerrit Code Review and JGit projects to remove 
> dependency on JSch library: [1], [2]. Instead, MINA SSSD should be used on 
> both: client and server sides.
> One difficulty we are facing is the fact the MINA SSHD currently doesn't 
> provide any means to export generated KeyPair in OpenSSH format.
> Thomas Wolf added recently the ability to read encrypted OpenSSH private keys 
> in context of SSHD-708.
> With JSch this code would do the job:
> {code:java}
>   public static com.jcraft.jsch.KeyPair genSshKey() throws JSchException {
> JSch jsch = new JSch();
> return KeyPair.genKeyPair(jsch, KeyPair.ECDSA, 256);
>   }
>   public static String publicKey(com.jcraft.jsch.KeyPair sshKey, @Nullable 
> String comment)
>   throws UnsupportedEncodingException {
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> sshKey.writePublicKey(out, comment);
> return out.toString(US_ASCII.name()).trim();
>   }
>   public static byte[] privateKey(com.jcraft.jsch.KeyPair keyPair) {
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> keyPair.writePrivateKey(out);
> return out.toByteArray();
>   }
> {code}
> [1] [https://bugs.eclipse.org/bugs/show_bug.cgi?id=540727]
>  [2] [https://bugs.chromium.org/p/gerrit/issues/detail?id=12599]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org