Skip to content

Instantly share code, notes, and snippets.

@krmahadevan
Created October 28, 2011 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krmahadevan/1321719 to your computer and use it in GitHub Desktop.
Save krmahadevan/1321719 to your computer and use it in GitHub Desktop.
Steps to recreate the sshj issue
1. create a ‘~/.ssh/config’ file with the following content;
#
# All hosts defaults
#
Host *
Protocol 1,2
FallBackToRsh no
ForwardAgent yes
ForwardX11 yes
PasswordAuthentication yes
RhostsAuthentication no
RhostsRSAAuthentication no
RSAAuthentication yes
NoHostAuthenticationForLocalhost yes
StrictHostKeyChecking no
KeepAlive yes
2. now for this user id, connect to a remote UNIX machine. The moment you connect to a UNIX remote machine, you will see the RSA1 come up.
3. Verify that the key got added up to your ~/.ssh/known_hosts file.
4. Create a SSHv1 compatible key pair using the command "ssh-keygen -t rsa1".
This command will create identity(private key) and identity.pub (public key) and save it under ~/.ssh folder.
5. Verify that the public key looks like a sshv1 key by running cat ~/.ssh/identity.pub
6. Now try to do a passwordless setup to a remote machine, so that no password is asked by running scp ~/.ssh/identity.pub <username>@<machinename>:~/.ssh/
7. Now append it to the authorized keys by running cat ~/.ssh/identity.pub > ~/.ssh/authorized_keys on the remote machine.
8. Verify that the passwordless setup was indeed completed by running ssh <userName>@<machineName> from your local machine, and you shouldn't be prompted for a password.
9. Now try to run the following sample program to simulate the problem from your local machine.
SSHClient client = new SSHClient();
client.loadKnownHosts();
client.connect(REMOTE_MACHINE);
client.authPassword(USERNAME, PASSWORD);
Session session = client.startSession();
Command command = session.exec("who am i");
String output = command.getOutputAsString();
System.out.println(output);
session.close();
client.close();
@hierynomus
Copy link

Could you get these same logs from your CI server?

@krmahadevan
Copy link
Author

@jeroen,

Here are the logs from the CI server

[:1001]==>ssh -v -v -v coonradt@stage2sc5403.sc4.com
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
debug1: Reading configuration data /x/home/coonradt/.ssh/config
debug1: Applying options for *
debug1: /x/home/coonradt/.ssh/config line 6: Deprecated option "FallBackToRsh"
debug1: /x/home/coonradt/.ssh/config line 10: Deprecated option "RhostsAuthentication"
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to stage2sc5403.sc4.com [10.15.24.241] port 22.
debug1: Connection established.
debug1: identity file /x/home/coonradt/.ssh/identity type 0
debug3: Not a RSA1 key file /x/home/coonradt/.ssh/id_rsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /x/home/coonradt/.ssh/id_rsa type 1
debug3: Not a RSA1 key file /x/home/coonradt/.ssh/id_dsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /x/home/coonradt/.ssh/id_dsa type 2
debug1: loaded 3 keys
debug1: Remote protocol version 1.99, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH*
debug1: Local version string SSH-1.5-OpenSSH_4.3
debug2: fd 3 setting O_NONBLOCK
debug1: Waiting for server public key.
debug1: Received server public key (768 bits) and host key (2048 bits).
debug3: check_host_in_hostfile: filename /x/home/coonradt/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 183
debug3: check_host_in_hostfile: filename /x/home/coonradt/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 183
debug1: Host 'stage2sc5403.sc4.com' is known and matches the RSA1 host key.
debug1: Found key in /x/home/coonradt/.ssh/known_hosts:183
debug1: Encryption type: 3des
debug1: Sent encrypted session key.
debug2: cipher_init: set keylen (16 -> 32)
debug2: cipher_init: set keylen (16 -> 32)
debug1: Installing crc compensation attack detector.
debug1: Received encrypted confirmation.
debug1: Trying RSA authentication with key '/x/home/coonradt/.ssh/identity'
debug1: Received RSA challenge from server.
debug1: Sending response to host key RSA challenge.
debug1: Remote: RSA authentication accepted.
debug1: RSA authentication accepted by server.
debug1: Requesting pty.
debug3: tty_make_modes: ospeed 9600
debug3: tty_make_modes: ispeed 9600
debug3: tty_make_modes: 1 3
debug3: tty_make_modes: 2 28
debug3: tty_make_modes: 3 127
debug3: tty_make_modes: 4 21
debug3: tty_make_modes: 5 4
debug3: tty_make_modes: 6 0
debug3: tty_make_modes: 7 0
debug3: tty_make_modes: 8 17
debug3: tty_make_modes: 9 19
debug3: tty_make_modes: 10 26
debug3: tty_make_modes: 12 18
debug3: tty_make_modes: 13 23
debug3: tty_make_modes: 14 22
debug3: tty_make_modes: 18 15
debug3: tty_make_modes: 30 0
debug3: tty_make_modes: 31 0
debug3: tty_make_modes: 32 0
debug3: tty_make_modes: 33 0
debug3: tty_make_modes: 34 0
debug3: tty_make_modes: 35 0
debug3: tty_make_modes: 36 1
debug3: tty_make_modes: 37 0
debug3: tty_make_modes: 38 1
debug3: tty_make_modes: 39 1
debug3: tty_make_modes: 40 0
debug3: tty_make_modes: 41 1
debug3: tty_make_modes: 50 1
debug3: tty_make_modes: 51 1
debug3: tty_make_modes: 52 0
debug3: tty_make_modes: 53 1
debug3: tty_make_modes: 54 1
debug3: tty_make_modes: 55 0
debug3: tty_make_modes: 56 0
debug3: tty_make_modes: 57 0
debug3: tty_make_modes: 58 0
debug3: tty_make_modes: 59 1
debug3: tty_make_modes: 60 1
debug3: tty_make_modes: 61 1
debug3: tty_make_modes: 62 1
debug3: tty_make_modes: 70 1
debug3: tty_make_modes: 71 0
debug3: tty_make_modes: 72 1
debug3: tty_make_modes: 73 0
debug3: tty_make_modes: 74 0
debug3: tty_make_modes: 75 0
debug3: tty_make_modes: 90 1
debug3: tty_make_modes: 91 1
debug3: tty_make_modes: 92 0
debug3: tty_make_modes: 93 0
debug2: fd 3 setting TCP_NODELAY
debug1: Requesting shell.
debug1: Entering interactive session.
debug2: fd 0 setting O_NONBLOCK
debug1: fd 0 clearing O_NONBLOCK
Last login: Mon Oct 24 16:59:19 2011 from 10.244.44.71
Red Hat Enterprise Linux Server release 5.4 (Tikanga)
-bash2-3.2$

@krmahadevan
Copy link
Author

Jeroen,

Please let me know incase you require any further information from me on this.

@hierynomus
Copy link

Hi Krishan,

I know enough, somehow the SSH client on your CI machine is forcing SSHv1. However SSHv1 support is not yet built, and far as I know this is not supported in any of the open source SSH libraries. If you can find one, I'd be very grateful and will have an easier time building it in in SSHJ. For now I will continue on implementing SSHv1 support.

Regards,
Jeroen

@krmahadevan
Copy link
Author

krmahadevan commented Jan 19, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment