पर bouncycastle के बजाय स्पॉन्स्कासल के साथ जेएसएच वर्तमान में मेरे पास एक पासवर्ड का उपयोग कर एसएसएच के माध्यम से मेरे राउटर से कनेक्ट एक एंड्रॉइड एप्लिकेशन है। मैं इसे सुधारने की सोच रहा हूं इसलिए मैं चाबियों का उपयोग कर सकता हूं लेकिन मुझे असली समस्याएं हैं। मैं समझता हूं कि एंड्रॉइड के साथ शामिल बाउंसीकैसल का संस्करण एक अपंग संस्करण है और इस एसएसएच कुंजी के कारण जेएसएच के साथ काम नहीं करते हैं। मैंने spongycastle को देखा है जो एक पूर्ण कार्यान्वयन का दावा करता है। नीचे वह परिणाम है जो मूल रूप से बाउंसीकैसल, औथ फ़ेल का उपयोग करने जैसा ही है।एंड्रॉइड
10-26 18:18:23.528: INFO/System.out(10642): Log(jsch,1): Connecting to 192.168.88.1 port 22
10-26 18:18:23.538: INFO/System.out(10642): Log(jsch,1): Connection established
10-26 18:18:23.548: INFO/System.out(10642): Log(jsch,1): Remote version string: SSH-2.0-ROSSSH
10-26 18:18:23.548: INFO/System.out(10642): Log(jsch,1): Local version string: SSH-2.0-JSCH-0.1.44
10-26 18:18:23.548: INFO/System.out(10642): Log(jsch,1): CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
10-26 18:18:23.618: INFO/System.out(10642): Log(jsch,1): SSH_MSG_KEXINIT sent
10-26 18:18:23.618: INFO/System.out(10642): Log(jsch,1): SSH_MSG_KEXINIT received
10-26 18:18:23.628: INFO/System.out(10642): Log(jsch,1): kex: server->client aes128-cbc hmac-md5 none
10-26 18:18:23.628: INFO/System.out(10642): Log(jsch,1): kex: client->server aes128-cbc hmac-md5 none
10-26 18:18:23.688: INFO/System.out(10642): Log(jsch,1): SSH_MSG_KEXDH_INIT sent
10-26 18:18:23.688: INFO/System.out(10642): Log(jsch,1): expecting SSH_MSG_KEXDH_REPLY
10-26 18:18:24.058: INFO/System.out(10642): Log(jsch,1): ssh_dss_verify: signature true
10-26 18:18:24.058: INFO/System.out(10642): Log(jsch,2): Permanently added '192.168.88.1' (DSA) to the list of known hosts.
10-26 18:18:24.058: INFO/System.out(10642): Log(jsch,1): SSH_MSG_NEWKEYS sent
10-26 18:18:24.058: INFO/System.out(10642): Log(jsch,1): SSH_MSG_NEWKEYS received
10-26 18:18:24.078: INFO/System.out(10642): Log(jsch,1): SSH_MSG_SERVICE_REQUEST sent
10-26 18:18:24.088: INFO/System.out(10642): Log(jsch,1): SSH_MSG_SERVICE_ACCEPT received
10-26 18:18:24.108: INFO/System.out(10642): Log(jsch,1): Authentications that can continue: publickey,keyboard-interactive,password
10-26 18:18:24.108: INFO/System.out(10642): Log(jsch,1): Next authentication method: publickey
10-26 18:18:24.108: INFO/System.out(10642): Log(jsch,1): Authentications that can continue: password
10-26 18:18:24.118: INFO/System.out(10642): Log(jsch,1): Next authentication method: password
10-26 18:18:24.128: INFO/System.out(10642): Log(jsch,1): Disconnecting from 192.168.88.1 port 22
10-26 18:18:24.138: WARN/System.err(10642): com.jcraft.jsch.JSchException: Auth fail
वहाँ jsch से जानकारी लॉग इन करने के लिए मुझे बाहर काम क्या गलत है मदद करने के लिए के एक महान सौदा नहीं है।
मुझे लगता है कि मैं इस के लिए बहुत मानक कोड का उपयोग कर रहा:
static {
Security.addProvider(new org.spongycastle.jce.provider.BouncyCastleProvider());
}
OnCreate में मैं मूल bouncycastle प्रदाता
Security.removeProvider("BC");
तो मैं पहचान जोड़ने को हटाने कर रहा हूँ बस कनेक्ट करने के लिए प्रयास करने से पहले
jsch.addIdentity(key_filename);
Properties sshProp = new Properties();
sshProp.put("StrictHostKeyChecking", "no");
session.setConfig(sshProp);
session.connect();
क्या किसी ने इसे सफलतापूर्वक किया है? क्या मैं कुछ भूल रहा हूँ?
संपादित बिंदु अतिरिक्त जानकारी:
जैसा कि मैंने कहा टिप्पणी में मैं अब शक रहा है कि कुंजी भी कोशिश की जा रही है जब मैं कुंजी और sshd संस्करण OpenSSH_5.3p1 डेबियन-3ubuntu7
पर परीक्षण के लिए स्विच
debug2: mac_setup: found hmac-md5
debug1: kex: client->server aes128-ctr hmac-md5 none
debug2: mac_setup: found hmac-md5
debug1: kex: server->client aes128-ctr hmac-md5 none
debug2: dh_gen_key: priv key bits set: 122/256
debug2: bits set: 519/1024
debug1: expecting SSH2_MSG_KEXDH_INIT
debug2: bits set: 537/1024
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: monitor_read: 5 used once, disabling now
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: KEX done
debug1: userauth-request for user root service ssh-connection method none
debug1: attempt 0 failures 0
debug2: parse_server_config: config reprocess config len 638
debug2: input_userauth_request: setting up authctxt for root
debug2: input_userauth_request: try method none
debug2: monitor_read: 7 used once, disabling now
debug1: PAM: initializing for "root"
debug1: PAM: setting PAM_RHOST to "nexus"
debug1: PAM: setting PAM_TTY to "ssh"
debug2: monitor_read: 50 used once, disabling now
debug2: monitor_read: 3 used once, disabling now
Failed none for root from 192.168.88.31 port 37807 ssh2
debug1: userauth-request for user root service ssh-connection method password
debug1: attempt 1 failures 0
debug2: input_userauth_request: try method password
debug1: PAM: password authentication failed for root: Authentication failure
Failed password for root from 192.168.88.31 port 37807 ssh2
Received disconnect from 192.168.88.31: 3: com.jcraft.jsch.JSchException: Auth fail
debug1: do_cleanup
debug1: do_cleanup
debug1: PAM: cleanup
मैं कुंजी का उपयोग करने का कोई प्रयास नहीं देख सकते हैं, जबकि
एक पीसी से
debug1: userauth-request for user root service ssh-connection method publickey
debug1: attempt 1 failures 0
debug2: input_userauth_request: try method publickey
debug1: test whether pkalg/pkblob are acceptable
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: temporarily_use_uid: 0/0 (e=0/0)
debug1: trying public key file /root/.ssh/authorized_keys
debug1: restore_uid: 0/0
debug1: temporarily_use_uid: 0/0 (e=0/0)
debug1: trying public key file /root/.ssh/authorized_keys2
debug1: fd 4 clearing O_NONBLOCK
debug1: matching key found: file /root/.ssh/authorized_keys2, line 2
मैं देख सकता हूँ कुंजी विधि का इस्तेमाल किया जा रहा है। नीचे कोड है जो मैं परीक्षण के लिए उपयोग कर रहा हूं, सुंदर लेकिन कार्यात्मक नहीं। मैं जानता हूँ कि यह भयानक है, लेकिन पासवर्ड फ़ाइल नाम और कुंजी के पथ शामिल करता है प्रयोग की जाने वाली AuthType == AUTHENTICATION_METHOD_KEY
public static String testSSHCommand (String username, String password, String hostname, int port, String command, int authtype) throws Exception {
JSch jsch = new JSch();
JSch.setLogger(new Logger() {
public boolean isEnabled(int i) {
return true;
}
public void log(int i, String s) {
System.out.println("Log(jsch," + i + "): " + s);
}
});
if (authtype != AUTHENTICATION_METHOD_PASSWORD) {
Log.v("AUTHMETHOD","authmethod was "+authtype+" with key filename of "+password);
jsch.addIdentity(password);
}
Session session = jsch.getSession(username, hostname, 22);
if (authtype != AUTHENTICATION_METHOD_KEY) {
session.setPassword(password);
}
Properties prop = new Properties();
prop.put("StrictHostKeyChecking", "no");
session.setConfig(prop);
session.connect();
if (session.isConnected()) {
ChannelExec channelssh = (ChannelExec)
session.openChannel("exec");
ByteArrayOutputStream os = new ByteArrayOutputStream();
channelssh.setOutputStream(os);
channelssh.setCommand(command);
channelssh.connect();
channelssh.disconnect();
return os.toString();
} else {
return "";
}
}
मुझे संदेह है कि आप गलत सार्वजनिक कुंजी का उपयोग कर रहे हैं। क्या एक ही कुंजी फाइल (सार्वजनिक + निजी) के साथ लॉगिन सामान्य पीसी जावा प्रोग्राम से काम करता है? –
मैं पीसी आधारित जावा विकास नहीं करता, हालांकि चाबियाँ ठीक हैं, मैं परीक्षण के लिए सर्वर बॉक्स में एसएसएच के लिए अपने पीसी पर उनका उपयोग कर सकता हूं। मुझे वास्तव में संदेह करना शुरू हो रहा है कि चाबियाँ भी कोशिश नहीं की जा रही हैं।(संपादन देखें) – Fuzzy
एक सामान्य पीसी जावा के साथ इसकी तुलना करने से समस्या को अलग करने में मदद मिलेगी, यानी यदि यह आपके क्रिप्टो प्रदाता या अपने कोड से संबंधित है। –