ssh - Java JSchException: Auth cancel -


i seeing issue when attempting ssh box using jsch. have tested connection using cygwin , connects seamlessly. have generated keypair , placed public key in authorized_keys file on remote server.

below extract logs

info: next authentication method: publickey info: authentications can continue: keyboard-interactive,password info: next authentication method: keyboard-interactive info: authentications can continue: password info: next authentication method: password info: disconnecting xx.xx.xx.xx port 22 com.jcraft.jsch.jschexception: auth cancel 

code used established connection

properties config = new properties(); config.put("cipher",",aes256-cbc"); config.put("mac.c2s", "hmac-sha2-256"); config.put("kexs", "diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256"); config.put("stricthostkeychecking", "no"); session session = jsch.getsession(username,host,port); session.setpassword(password); session.setuserinfo(ui); session.setconfig(config); session.getport(); session.connect(); session.setportforwardingl(tunnellocalport,tunnelremotehost,tunnelremoteport); 

here code userinfo ui

string password = null;  @override public string getpassphrase() {     return null; } @override public string getpassword() {     return password; } public void setpassword(string passwd) {     password = passwd; }  @override public boolean promptpassphrase(string message) {     return false; } @override public boolean promptpassword(string message) {     return false; } @override public boolean promptyesno(string message) {     return false; } 

it looks jsch isn't trying use key file, because code doesn't tell jsch key file use. need call jsch.addidentity() add 1 or more key files session:

jsch.addidentity("c:\users\jdoe\.ssh\id_rsa"); 

or

string passphrase = ...; jsch.addidentity("c:\users\jdoe\.ssh\id_rsa",                  passphrase.getbytes()); 

there other varieties of addidentity() function, if want supply information in other format.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -