jcabi-ssh icon indicating copy to clipboard operation
jcabi-ssh copied to clipboard

add support for option to ignore unknown host warning

Open grexe opened this issue 10 years ago • 5 comments

It's quite common that you connect to a server for the first time, and you get the "unknown host" warning:

The authenticity of host '1.2.3.4 can't be established. ... Are you sure you want to continue connecting (yes/no)?

This is a serious problem, because you get an interactive prompt that makes the jcabi library fail because it cannot establish a connection:

java.io.IOException: com.jcraft.jsch.JSchException: Algorithm negotiation fail

In ssh, you can bypass the host warning by passing the StrictHostKeyChecking option and another trick:

 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no

Some kind of support for this would be needed for jcabi imo.

grexe avatar Nov 16 '15 21:11 grexe

@yegor256 please pay attention to this issue (par.21)

dmarkov avatar Nov 23 '15 10:11 dmarkov

@grexe we already solve this problem, see https://github.com/jcabi/jcabi-ssh/blob/1.5/src/main/java/com/jcabi/ssh/SSH.java#L260 and EasyRepo. I think that there is some other problem on your side.

yegor256 avatar Nov 28 '15 19:11 yegor256

I see - thanks for the info, I seem to have overlooked this, sorry.

grexe avatar Nov 29 '15 21:11 grexe

One downside to the change made in 1.5 is that it always ignores the remote host public key now. This opens up applications that use this library to a MitM attack.

Could this be changed as an optional setting so the default secure setting is retained?

Ideally $HOME/.ssh/known_hosts would be loaded as a default if it exists. If not it would be nice to show example code on how to load a known host public key as trusted versus disabling the check altogether and opening up the user for MitM attacks.

rbeede avatar Feb 17 '17 16:02 rbeede

this issue is not really solved until there's a way to properly validate the server host key (e.g. by specifying a known_hosts file content or letting the client implement the jsch HostKeyRepository interface)

rgl avatar Nov 19 '17 11:11 rgl