[jbosstools-issues] [JBoss JIRA] (JBIDE-12016) OpenShift Wizard should warn if domain exists but there's no ssh key on local machine (domain was created in web ui)

Andre Dietisheim (JIRA) jira-events at lists.jboss.org
Tue Sep 11 06:24:33 EDT 2012


    [ https://issues.jboss.org/browse/JBIDE-12016?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12716606#comment-12716606 ] 

Andre Dietisheim edited comment on JBIDE-12016 at 9/11/12 6:22 AM:
-------------------------------------------------------------------

To warn of possible issues before the cloning happens, I tried to find a way to verify keys on the local machine before the cloning happens. 

The code in Apache Mina (http://mina.apache.org/) shows pretty well how the basic scheme works.
The client signs a payload using the private key and sends it to the server. The server then verifies the signature with the public key:

The client (UserAuthPublicKey#next (http://svn.apache.org/repos/asf/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java) instantiates some providers (http://svn.apache.org/repos/asf/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/common/signature/SignatureDSA.java) that internally use java.security.Signature:

{code}
Signature verif = NamedFactory.Utils.create(session.getFactoryManager().getSignatureFactories(), (key.getPublic() instanceof RSAPublicKey) ? KeyPairProvider.SSH_RSA : KeyPairProvider.SSH_DSS);
{code}

It then builds up a buffer with a payload that contains the public key:

{code}
Buffer bs = new Buffer();
bs.putString(session.getKex().getH());
bs.putCommand(SshConstants.Message.SSH_MSG_USERAUTH_REQUEST);
bs.putString(username);
bs.putString("ssh-connection");
bs.putString("publickey");
bs.putByte((byte) 1);
bs.putString((key.getPublic() instanceof RSAPublicKey) ? KeyPairProvider.SSH_RSA : KeyPairProvider.SSH_DSS);
bs.putPublicKey(key.getPublic());
{code}

and then signs it...

{code}
bs.putBytes(verif.sign());
{code}

Signing is done using the private key:
http://svn.apache.org/repos/asf/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/common/signature/AbstractSignature.java
{code}
signature.initSign(prvkey);
{code}

...and sends it to the server

{code}
buffer.putBytes(bs.array(), bs.rpos(), bs.available());
session.writePacket(buffer);
{code}

The server (UserAuthPublicKey#next - http://svn.apache.org/repos/asf/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPublicKey.java) 
initializes some signature providers...

{code}
Signature verif = NamedFactory.Utils.create(session.getFactoryManager().getSignatureFactories(), keyAlg);
verif.init(key, null);
...
{code}

...builds some payload...

{code}
Buffer buf = new Buffer();
buf.putString(session.getKex().getH());
buf.putCommand(SshConstants.Message.SSH_MSG_USERAUTH_REQUEST);
buf.putString(username);
buf.putString("ssh-connection");
buf.putString("publickey");
buf.putByte((byte) 1);
buf.putString(keyAlg);
buffer.rpos(oldPos);
buffer.wpos(oldPos + 4 + len);
buf.putBuffer(buffer);
{code}

...and verifies the signature

{code}
if (!verif.verify(sig)) {
   throw new Exception("Key verification failed");
}
{code}

Verifying the signaure is done using the public key:
http://svn.apache.org/repos/asf/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/common/signature/AbstractSignature.java
{code}
signature.initVerify(pubkey);
{code}

                
      was (Author: adietish):
    To warn of possible issues before the cloning happens, I tried to find a way to verify keys on the local machine before the cloning happens. 

The code in Apache Mina (http://mina.apache.org/) shows pretty well how the basic scheme works.
The client signs a payload using the private key and sends it to the server. The server then verifies the signature with the public key:

The client (UserAuthPublicKey#next (http://svn.apache.org/repos/asf/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/client/auth/UserAuthPublicKey.java) instantiates some providers (http://svn.apache.org/repos/asf/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/common/signature/SignatureDSA.java) that internally use java.security.Signature:

{code}
Signature verif = NamedFactory.Utils.create(session.getFactoryManager().getSignatureFactories(), (key.getPublic() instanceof RSAPublicKey) ? KeyPairProvider.SSH_RSA : KeyPairProvider.SSH_DSS);
{code}

It then builds up a buffer with a payload that contains the public key:

{code}
Buffer bs = new Buffer();
bs.putString(session.getKex().getH());
bs.putCommand(SshConstants.Message.SSH_MSG_USERAUTH_REQUEST);
bs.putString(username);
bs.putString("ssh-connection");
bs.putString("publickey");
bs.putByte((byte) 1);
bs.putString((key.getPublic() instanceof RSAPublicKey) ? KeyPairProvider.SSH_RSA : KeyPairProvider.SSH_DSS);
bs.putPublicKey(key.getPublic());
{code}

and then signs it...

{code}
bs.putBytes(verif.sign());
{code}

...and sends it to the server

{code}
buffer.putBytes(bs.array(), bs.rpos(), bs.available());
session.writePacket(buffer);
{code}

The server (UserAuthPublicKey#next - http://svn.apache.org/repos/asf/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/auth/UserAuthPublicKey.java) 
initializes some signature providers...

{code}
Signature verif = NamedFactory.Utils.create(session.getFactoryManager().getSignatureFactories(), keyAlg);
verif.init(key, null);
...
{code}

...builds some payload...

{code}
Buffer buf = new Buffer();
buf.putString(session.getKex().getH());
buf.putCommand(SshConstants.Message.SSH_MSG_USERAUTH_REQUEST);
buf.putString(username);
buf.putString("ssh-connection");
buf.putString("publickey");
buf.putByte((byte) 1);
buf.putString(keyAlg);
buffer.rpos(oldPos);
buffer.wpos(oldPos + 4 + len);
buf.putBuffer(buffer);
{code}

...and verifies the signature

{code}
if (!verif.verify(sig)) {
   throw new Exception("Key verification failed");
}
{code}
                  
> OpenShift Wizard should warn if domain exists but there's no ssh key on local machine (domain was created in web ui)
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: JBIDE-12016
>                 URL: https://issues.jboss.org/browse/JBIDE-12016
>             Project: Tools (JBoss Tools)
>          Issue Type: Enhancement
>          Components: openshift
>    Affects Versions: 3.3.0.Beta3
>            Reporter: Burr Sutter
>            Assignee: Andre Dietisheim
>             Fix For: 4.0.0.Alpha2
>
>         Attachments: cloning-settings.png, Screen Shot 2012-05-25 at 10.57.18 AM.png
>
>
> If the end-user's .ssh directory is empty - we should provide a stronger warning for them - ideally provide a URL to some documentation/video explaining how the user can use Eclipse/JBoss Tools to create their private/public keys - so they can then upload the .pub to OpenShift.
> At least 10 users failed this test today and had to be "handheld" through the process.   
> What is worse, if the end-user uploads a slightly butchered pub key - the create application phase still works but the git clone fails - with a relatively poor error message - recovery normally means having to go up to the OpenShift console, deleting the poorly created apps - getting the pub key uploaded correctly (deleting the previous one) and starting again.
> The fact that Eclipse could create the keys was actually unknown by the instructor's of today's class.  SSH is still a nightmare for the newbie trying to use OpenShift + JBDS.
> How to reproduce:
> 1. ASSERT: make sure you have an OpenShift user without a domain (create a new user or kill your users domain)
> 2. EXEC: launch *OpenShift Application* wizard and create a new application
> Result:
> Cloning fails, since there are no ssh-keys on the local machine and no keys were added to OpenShift. The wizard did not tell the user since the domain already existed. The domain creation dialog is currently the only place that would allow a user to create a new ssh-key. If you already have a domain, you'll never get asked to create your keys.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jbosstools-issues mailing list