Hi,

I'm facing an issue about ssh session with ~/.ssh/config :

I have a remote host toto.titi.fr accessible on the port 2222. Due to a 
limitation of the framework I'm using (which uses jsch to connect to a remote 
git repository), I had to define the uri like that 
usern...@toto.titi.fr:path/to/my/repo<mailto:usern...@toto.titi.fr:path/to/my/repo>
 and added a config file with the configuration

## redirection port
Host toto.titi.fr
     HostName toto.titi.fr
     HostKeyAlias toto.titi.fr
     Port 2222
     User username

Unfortunately when jsch try to connect (session.connect(tms) I got a 
NullPointerException from the method checkHost(host, port, kex) whereas it load 
the key list (line 801).

HostKey[] keys =
        hkr.getHostKey(chost,
                       (key_type.equals("DSA") ? "ssh-dss" : "ssh-rsa"));


Finally,  keys is null. So the line 805 (for(int j=0; j< keys.length; j++){) 
throws a NullPointerException.

The problem is located on the method getHostKey of HostKeyRepository. The 
library try to identify in the known_hosts file the remote host key. So It 
loops and as it finds the matched item it returns it. If no key found it 
returns null. In my case it returns null because the library compares the 
following chost  :

"[toto.titi.fr]:2222" (because of the rule (line 709 at Session.class) which 
modify the defaut chost value ("toto.titi.fr") when no HostKeyAlias is set and 
port different than 22.

to  the key in my known_hosts file which looks like :

toto.titi.fr,1.2.3.4 ssh-rsa AAAAB3Nz....C+6e/.... /9MrXset+YG/aYLMZMzG+e31PET

Why the chost is formatted like that when the port used is not the default one?


To workaround, I had to delete in my known_hosts file the key but it's not a 
good idea. The problem occurs if someone connect to the remote host with ssh 
util.

My second idea, was to used a HostKeyAlias but it not set at line 698 in the 
checkHost method. How can I fix the problem?

Regards

RaphC











________________________________

L'intégrité de ce message n'étant pas assurée sur internet, la société 
expéditrice ne peut être tenue responsable de son contenu ni de ses pièces 
jointes. Toute utilisation ou diffusion non autorisée est interdite. Si vous 
n'êtes pas destinataire de ce message, merci de le détruire et d'avertir 
l'expéditeur.

The integrity of this message cannot be guaranteed on the Internet. The company 
that sent this message cannot therefore be held liable for its content nor 
attachments. Any unauthorized use or dissemination is prohibited. If you are 
not the intended recipient of this message, then please delete it and notify 
the sender.
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to