JSch connection with public key
843811Nov 3 2005 — edited Nov 22 2005I am having trouble getting JSch to connect using a public key. It works fine with user/pw. It says on the server side's daemon that the keys do not match. I do not understand why it says on the first line of the output that the ssh-connection completed, and then it says the keys do not match. Any help would be greatly appreciated. I have verified that the keys do match, they are the same size, the same time, and were transmitted in binary. I have also regenerated them several times, and made sure each time they were correct, no dice. Thanks,
Code :
=====================================================================================
int port = 22;
System.setProperty("SSH_KEY_LOCATION", "w:/keys/test_pc.pub");
protected com.jcraft.jsch.Session openSession() throws JSchException {
userInfo = new SSHUserInfo();
userInfo.setKeyfile(System.getProperty("SSH_KEY_LOCATION"));
userInfo.setName("theparmster");
JSch jsch = new JSch();
jsch.addIdentity(userInfo.getKeyfile());
com.jcraft.jsch.Session session = jsch.getSession(userInfo.getName(), host, port);
session.setUserInfo(userInfo);
Hashtable table = new Hashtable();
table.put("StrictHostKeyChecking", "no");
table.put("server_host_key", "ssh-dss");
session.setConfig(table);
System.out.println("Connecting to " + host + ":" + port + " with : " + System.getProperty("SSH_KEY_LOCATION"));
/* Dies on this call */
session.connect();
System.out.println("Connect finished.");
return session;
}
=====================================================================================
Output :
"Connecting to 192.168.253.160:22 with : w:/keys/test_pc.pub
com.jcraft.jsch.JSchException: Auth cancel
at com.jcraft.jsch.Session.connect(Unknown Source)
at com.jcraft.jsch.Session.connect(Unknown Source)
at client.UserClass.openSession(UserClass.java:842)
...
"
=====================================================================================
Running the ssh daemon in debug mode -99 I received this output :
...
debug[29907]: Sshd2/sshd2.c:1138/auth_policy_proc: user 'theparmster' service 'ssh-connection' client_ip '192.168.189.53' client_port '2083' completed ''^M
debug[29907]: Sshd2/sshd2.c:1191/auth_policy_proc: Number of groups: 2.^M
debug[29907]: Sshd2/sshd2.c:1196/auth_policy_proc: Adding group: adimss, 58.^M
debug[29907]: Sshd2/sshd2.c:1196/auth_policy_proc: Adding group: cmgrp, 110.^M
debug[29907]: Sshd2/sshd2.c:1568/auth_policy_proc: output: publickey,password^M
debug[29907]: SshEncode/sshencode.c:42/encode_buffer_va_internal: Format = 0x2^M
debug[29907]: SshEncode/sshencode.c:42/encode_buffer_va_internal: Format = 0x5^M
debug[29907]: SshEncode/sshencode.c:42/encode_buffer_va_internal: Format = 0xD0E0A0D^M
debug[29907]: SshEncode/sshencode.c:42/encode_buffer_va_internal: Format = 0x5^M
debug[29907]: SshEncode/sshencode.c:42/encode_buffer_va_internal: Format = 0x0^M
debug[29907]: SshEncode/sshencode.c:42/encode_buffer_va_internal: Format = 0x3^M
debug[29907]: SshEncode/sshencode.c:42/encode_buffer_va_internal: Format = 0xD0E0A0D^M
debug[29907]: SshEventLoop/sshunixeloop.c:667/ssh_register_timeout: Timeout registered at 1130945896.^M
debug[29907]: SshEventLoop/sshunixeloop.c:667/ssh_register_timeout: Timeout registered at 1130945896.^M
debug[29907]: Ssh2Transport/trcommon.c:3180/ssh_tr_process_up_incoming_packet: Processing packet from the application. (type: 0)^M
debug[29907]: Ssh2Transport/trcommon.c:3227/ssh_tr_process_up_incoming_packet: Padding auth packet with an SSH_MSG_IGNORE packet with 697 bytes of payload (payload_len = 1351).^M
debug[29907]: SshEncode/sshencode.c:42/encode_buffer_va_internal: Format = 0x5^M
debug[29907]: SshEncode/sshencode.c:42/encode_buffer_va_internal: Format = 0x2^M
debug[29907]: SshEncode/sshencode.c:42/encode_buffer_va_internal: Format = 0xD0E0A0D^M
debug[29907]: SshEncode/sshencode.c:42/encode_buffer_va_internal: Format = 0x5^M
debug[29907]: SshEncode/sshencode.c:42/encode_buffer_va_internal: Format = 0x0^M
debug[29907]: SshEncode/sshencode.c:42/encode_buffer_va_internal: Format = 0x3^M
debug[29907]: SshEncode/sshencode.c:42/encode_buffer_va_internal: Format = 0xD0E0A0D^M
debug[29907]: SshEventLoop/sshunixeloop.c:667/ssh_register_timeout: Timeout registered at 1130945896.^M
debug[29907]: SshEventLoop/sshunixeloop.c:667/ssh_register_timeout: Timeout registered at 1130945896.^M
debug[29907]: Ssh2Transport/trcommon.c:3180/ssh_tr_process_up_incoming_packet: Processing packet from the application. (type: 0)^M
debug[29907]: Ssh2Transport/trcommon.c:3227/ssh_tr_process_up_incoming_packet: Padding auth packet with an SSH_MSG_IGNORE packet with 1000 bytes of payload (payload_len = 24).^M
debug[29907]: SshEncode/sshencode.c:42/encode_buffer_va_internal: Format = 0x5^M
debug[29907]: SshEncode/sshencode.c:42/encode_buffer_va_internal: Format = 0x2^M
debug[29907]: SshEncode/sshencode.c:42/encode_buffer_va_internal: Format = 0xD0E0A0D^M
debug[29907]: Ssh2Transport/trcommon.c:227/tr_get_padding_byte: Running padding generator.^M
debug[29907]: Ssh2Transport/trcommon.c:227/tr_get_padding_byte: Running padding generator.^M
debug[29907]: Ssh2Transport/trcommon.c:227/tr_get_padding_byte: Running padding generator.^M
debug[29907]: Ssh2Transport/trcommon.c:227/tr_get_padding_byte: Running padding generator.^M
debug[29907]: Ssh2Transport/trcommon.c:227/tr_get_padding_byte: Running padding generator.^M
debug[29907]: Ssh2Transport/trcommon.c:227/tr_get_padding_byte: Running padding generator.^M
debug[29907]: Ssh2Transport/trcommon.c:227/tr_get_padding_byte: Running padding generator.^M
debug[29907]: Ssh2Transport/trcommon.c:227/tr_get_padding_byte: Running padding generator.^M
debug[29907]: Ssh2Transport/trcommon.c:227/tr_get_padding_byte: Running padding generator.^M
debug[29907]: Ssh2Transport/trcommon.c:227/tr_get_padding_byte: Running padding generator.^M
debug[29907]: SshRegex/sshregex.c:935/do_step: Thread=1fbecc delay=0^M
debug[29907]: SshRegex/sshregex.c:961/do_step: State=16 (1fa258).^M
debug[29907]: SshRegex/sshregex.c:961/do_step: State=20 (1fa138).^M
debug[29907]: SshRegex/sshregex.c:961/do_step: State=19 (1f9e38).^M
debug[29907]: SshRegex/sshregex.c:961/do_step: State=24 (1fa318).^M
debug[29907]: SshRegex/sshregex.c:773/kill_thread: Killing thread 1fbecc.^M
debug[29907]: SshConfig/sshconfig.c:3240/ssh_config_parse_line: n_var = `key', n_val = `test_pc.pub'^M
debug[29907]: Ssh2AuthPubKeyServer/auths-pubkey.c:807/ssh_server_auth_pubkey_verify: key 0, /users/theparmster/.ssh2/test_pc.pub^M
debug[29907]: SshUserFiles/sshkeyblob2.c:573/ssh2_key_blob_decode: key blob magic = 0x00000005^M
debug[29907]: Ssh2AuthPubKeyServer/auths-pubkey.c:931/ssh_server_auth_pubkey_verify: auth_pubkey_verify: the key didn't match.^M
debug[29907]: Ssh2AuthPubKeyServer/auths-pubkey.c:1408/ssh_server_auth_pubkey: auth_pubkey_verify returned FALSE^M
=====================================================================================