Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSch SFTP security with session.setConfig("StrictHostKeyChecking", "no");

I use JSch with private key to FTP file

  1. jsch.addIdentity(privatekeyfile);
  2. Session session = jsch.getSession( "user", "domain.com" ,22);
  3. session.setConfig("StrictHostKeyChecking", "no");

Line 3 is in question. Without this line, JSch does not work.

My question is: Will line 3 make SFTP transfer insecure?

like image 507
Tony Avatar asked May 11 '15 22:05

Tony


People also ask

What is StrictHostKeyChecking in SFTP?

Rejects incoming SSH host keys from remote servers not in the known host list. off. Accepts incoming SSH host keys from remote servers not in the known host list. This setting is the default value.

What is StrictHostKeyChecking in JSch?

Description​ The JSch StrictHostKeyChecking configuration is set to no, this indicates that connections may be made to unknown servers or servers that have changed their keys, generating new ones and adding them by default to the known server files.


1 Answers

Disabling the StrictHostKeyChecking option will make the connection less secure than having the option enabled, because it will let you connect to remote servers without verifying their SSH host keys. If the option is enabled, you will only be able to connect to servers which keys are known to your SSH client.

You will have to decide what that means for your specific use case - are the servers you are connecting on a private, local network or do you connect over the internet? Is this a testing or production environment?

When in doubt, it is better to err on the side of more security. I would recommend enabling StricktHostKeyChecking and using the setKnownHosts method to provide a file which contains the remote host keys.

like image 161
Ben Damer Avatar answered Sep 23 '22 23:09

Ben Damer