java - JSch scp without known_host file and with StrictHostKeyChecking -


i trying copy files windows machine linux machine, working fine jsch far. can copy files using stricthostkeychecking no or need have known_host file linux machine copy to. using code java project should able send files automatically (unknown) linux machines. got username, password, ip , publickey machine. there way authenticate without known_host file , via publickey? because of security issues not want switch stricthostkeychecking no "com.jcraft.jsch.jschexception: unknownhostkey"

fileinputstream fis = null; jsch jsch = new jsch();  //jsch.setknownhosts(""); jsch.addidentity("d:\\uni\\arbeit\\remote_id_rsa"); session session=jsch.getsession(user, host, 22); session.setpassword(password); //session.setconfig("stricthostkeychecking", "no"); session.connect(); 

that not make sense. either know host public key , can verify either using known_host file or programmatically using:

public void knownhosts.add(hostkey hostkey, userinfo userinfo) 

(you can access instance of knownhosts using session.gethostkeyrepository())

for more details, see how resolve java unknownhostkey, while using jsch sftp library?


or not know host public key, , cannot create secure connection (and stricthostkeychecking=no option).


see my article verifying host key understand, about, , importance. article winscp client, it's valid in general ssh client.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -