Closed dhubbard-ic closed 5 years ago
Hold off on this - I suspect this may be because my initial connect logic - just via key is incorrect - the "preauth" in the following probably means the session isn't logged in correctly.
Mar 9 20:33:10 localhost sshd[11339]: debug3: receive packet: type 90 [preauth]
Mar 9 20:33:10 localhost sshd[11339]: dispatch_protocol_error: type 90 seq 3 [preauth]
Mar 9 20:33:10 localhost sshd[11339]: debug3: send packet: type 3 [preauth]
Mar 9 20:33:10 localhost sshd[11339]: debug3: receive packet: type 1 [preauth]
Mar 9 20:33:10 localhost sshd[11339]: error: Received disconnect from 192.168.13.1 port 64332:2: Unexpected: SSH_MSG_UNIMPLEMENT
I will retry and update/close as appropriate
It was my mistake - I adapted the Jump sample and managed to remove the authPublicKey method - hence not authorised - just a bit confused by no "no authenticated" type error.
I will close this.
Here is my adaption which works
public class Jump {
public static void main(String... args)
throws IOException {
SSHClient firstHop = new SSHClient();
firstHop.addHostKeyVerifier(new PromiscuousVerifier());
String keyFile = "C:\\Keys\\MyLaptop.pem";
System.out.println("About to connect");
firstHop.connect("192.168.13.71");
try {
String user = "user";
firstHop.authPublickey(user, new String[] { keyFile });
System.out.println("Done connect");
System.out.println("About to Do a new direct connect");
DirectConnection tunnel = firstHop.newDirectConnection("localhost", 22);
System.out.println("Done direct connect");
SSHClient ssh = new SSHClient();
try {
System.out.println("Done direct connect");
ssh.addHostKeyVerifier(new PromiscuousVerifier());
ssh.connectVia(tunnel);
ssh.authPublickey(user, new String[] { keyFile });
System.out.println("Done connect via Tunnel");
final Session session = ssh.startSession();
try {
final Session.Command cmd = session.exec("ping -c 1 google.com");
System.out.println(IOUtils.readFully(cmd.getInputStream()).toString());
cmd.join(5, TimeUnit.SECONDS);
System.out.println("\n** exit status: " + cmd.getExitStatus());
} finally {
session.close();
}
}
catch (Exception ex) {
ex.printStackTrace();
} finally {
ssh.disconnect();
}
} finally {
firstHop.disconnect();
}
}
}
Output
[main] INFO net.schmizz.sshj.transport.random.BouncyCastleRandom - Generating random seed from SecureRandom.
About to connect
[main] INFO net.schmizz.sshj.transport.TransportImpl - Client identity string: SSH-2.0-SSHJ_0.21.2_SNAPSHOT
[main] INFO net.schmizz.sshj.transport.TransportImpl - Server identity string: SSH-2.0-OpenSSH_7.4
Done connect
About to Do a new direct connect
Done direct connect
[main] INFO net.schmizz.sshj.transport.random.BouncyCastleRandom - Generating random seed from SecureRandom.
Done direct connect
[main] INFO net.schmizz.sshj.transport.TransportImpl - Client identity string: SSH-2.0-SSHJ_0.21.2_SNAPSHOT
[main] INFO net.schmizz.sshj.transport.TransportImpl - Server identity string: SSH-2.0-OpenSSH_7.4
Done connect via Tunnel
PING google.com (216.58.214.14) 56(84) bytes of data.
64 bytes from lhr26s05-in-f14.1e100.net (216.58.214.14): icmp_seq=1 ttl=52 time=30.2 ms
--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 30.256/30.256/30.256/0.000 ms
** exit status: 0
[main] INFO net.schmizz.sshj.transport.TransportImpl - Disconnected - BY_APPLICATION
[main] INFO net.schmizz.sshj.transport.TransportImpl - Disconnected - BY_APPLICATION
Hi
I am trying out #337 and have cloned liff:jumping branch, which includes this commit
Trying this against Centos 7.6.1810 with OpenSSH 7.4 server (openssh-7.4p1-16.el7) - with an abridged version of Jump example - only changes made were to include using PromiscuousVerifier() and loadKeys() as on Windows rather than external ssh known_hosts etc.
The initial connect works but on I got the following:
Is this intended to support OpenSSH? and is there any expectation on server SSH version ? From what I read ProxyJump support was added in OpenSSH 7.3.
I apologise if this is the wrong place to post, but liff/sshj is not open for issues.
BTW - the "Client identity string: SSH-2.0-SSHJ_0.21.2_SNAPSHOT" label shows wrong version - this seems to come from a setting in the liff/sshj repo - I am not a gradle person so could not see a way of making this align with the version in hierynoums/sshj .
For completeness here is my version of Jump code