PyCharm不能ssh到远程解释器(com.jcraft.jsch.JSchException:Auth fail)

时间:2018-04-27 17:39:46

标签: ssh pycharm

我正在尝试使用PyCharm Professional连接到远程python解释器:

PyCharm 2018.1.2 (Professional Edition)
Build #PY-181.4668.75, built on April 25, 2018
JRE: 1.8.0_152-release-1136-b29 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.4

然而,即使我提供正确的ssh凭证,密钥,端口我仍然获得connection to james@192.168.11.10:22 failed: Authentication failure。在Mac OS上设置ssh远程解释器有秘密吗?

以下sshd日志记录显示我确实已连接到该框,但com.jcraft.jsch.JSchException: Auth fail正在断开连接。日志还表明密钥确实与authorized_keys匹配。是什么给了什么?

Apr 27 13:20:48 james-host sshd[4402]: error: Received disconnect from 192.168.11.1 port 53717:3: com.jcraft.jsch.JSchException: Auth fail [preauth]
Apr 27 13:20:48 james-host sshd[4402]: Disconnected from 192.168.11.1 port 53717 [preauth]

如果我深入研究sshd调试......

debug1: userauth-request for user james service ssh-connection method none [preauth]
debug1: attempt 0 failures 0 [preauth]
debug1: PAM: initializing for "james"
debug1: PAM: setting PAM_RHOST to "192.168.11.1"
debug1: PAM: setting PAM_TTY to "ssh"
debug1: userauth-request for user james service ssh-connection method publickey [preauth]
debug1: attempt 1 failures 0 [preauth]
debug1: userauth_pubkey: test whether pkalg/pkblob are acceptable for RSA SHA256:5tpn/jFTw9ZRebVhxY4+ogQJDfHn/QN9tFicV6tdHWc [preauth]
debug1: temporarily_use_uid: 1000/1000 (e=0/0)
debug1: trying public key file /home/james/.ssh/authorized_keys
debug1: fd 4 clearing O_NONBLOCK

# Matching key found...
debug1: matching key found: file /home/james/.ssh/authorized_keys, line 1 RSA SHA256:5tpn/jFTw9ZRebVhxY4+ogQJDfHn/QN9tFicV6tdHWc
debug1: restore_uid: 0/0
Postponed publickey for james from 192.168.11.1 port 53292 ssh2 [preauth]

# Auth fail??? What?
Received disconnect from 192.168.11.1 port 53292:3: com.jcraft.jsch.JSchException: Auth fail [preauth]
Disconnected from 192.168.11.1 port 53292 [preauth]
debug1: do_cleanup [preauth]
debug1: monitor_read_log: child log fd closed
debug1: do_cleanup
debug1: PAM: cleanup
debug1: Killing privsep child 4296
debug1: audit_event: unhandled event 12

1 个答案:

答案 0 :(得分:0)

我不确定上面的确切问题,但我能够通过两种不同的方法解决这个问题。

  1. 通过ssh启用密码验证。
  2. 我试过这个作为诊断措施,因为这显然是不安全的。 PyCharm能够连接。

    1. 生成新的ssh-key。将公钥部署到authorized_keys

      ssh-keygen -t rsa -b 4096

    2. 使用新的ssh密钥,我能够成功连接到远程Python解释器。这里唯一的区别是我没有密码保护我的私钥(它在我原来的问题中受到密码保护 - 我会尝试下一步)。