我已使用登录名和密码配置SFTP连接PyCharm 2019.3.3 (Build #PY-193.6494.30)
上的Mac OS 10.15.3
。当我尝试“测试SFTP连接”时,我没有收到任何错误,但出现了“永不超时”的“通过SFTP连接”循环。每次我重新安装PyCharm时,它都能工作2-3次,但此后,不再建立连接,并且出现了如上所述的连接循环。当我重新安装PyCharm时,请确保从〜/ Library中删除所有相关文件。正在通过VPN隧道建立连接。我可以完美地将ssh放入相同的部署地址,只有PyCharm无法连接。
我能够从日志中获取以下内容:
2020-03-02 15:22:42,945 [ 17190] DEBUG - t.connections.RemoteConnection - Opening connection to sftp://10.5.166.81:22/ in @6aab2a3e
2020-03-02 15:22:42,970 [ 17215] DEBUG - ntellij.ssh.impl.SshConnection - Failed to create SSH channel using existing SSH sessions, creating new SSH session
2020-03-02 15:22:42,970 [ 17215] DEBUG - ntellij.ssh.impl.SshConnection - Establishing new SSH session to [email protected]:22
2020-03-02 15:22:43,186 [ 17431] INFO - port.random.BouncyCastleRandom - Generating random seed from SecureRandom.
2020-03-02 15:22:43,603 [ 17848] INFO - z.sshj.transport.TransportImpl - Client identity string: SSH-2.0-SSHJ_0.27.0
2020-03-02 15:22:43,625 [ 17870] INFO - z.sshj.transport.TransportImpl - Server identity string: SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
2020-03-02 15:22:43,821 [ 18066] INFO - om.intellij.ssh.impl.sshj.sshj - Authentication log: SSHJ connection to [email protected]:22
* With preferred authentications: publickey,keyboard-interactive,password
* With signature factories: ssh-rsa, ssh-dss, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, ssh-ed25519
* With keep alive interval 300 seconds
* With keep alive count max 1000
* With OpenSshLikeHostKeyVerifier(knownHostsFile=[/Users/user/.ssh/known_hosts], strictHostKeyChecking=ASK, hashKnownHosts=false)
* With predefined password
* With authentications: password by net.schmizz.sshj.userauth.method.AuthPassword, keyboard-interactive by net.schmizz.sshj.userauth.method.AuthKeyboardInteractive
* With socketFactory com.intellij.ssh.sockets.MySftpJavaSocketFactory@630ddfb0
* With connect timeout 10000
* Connected
=> none by net.schmizz.sshj.userauth.method.AuthNone@24b009e5 (failure, new allowed auth methods: publickey, password)
=> password by net.schmizz.sshj.userauth.method.AuthPassword@108e1414 (success)
2020-03-02 15:22:43,825 [ 18070] DEBUG - ntellij.ssh.impl.SshConnection - SSH session @30c953a1 established to [email protected]:22
2020-03-02 15:22:43,825 [ 18070] DEBUG - ellij.ssh.SshConnectionService - Creating sftp channel within SshjSshConnection(<crc32=zov9y>@<crc32=1djyopl>)@30c953a1
2020-03-02 15:22:44,628 [ 18873] INFO - .channel.direct.SessionChannel - Will request `sftp` subsystem
我通常通过我的私密ssh密钥登录,但使用用户+密码登录也可以:
$ ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no 10.5.166.81
The authenticity of host '10.5.166.81 (10.5.166.81)' can't be established.
ECDSA key fingerprint is SHA256:ELdUhvqI6us+QR/CJRwb0u4a+zUcvWLUdZdWeYmhj2s.
Are you sure you want to continue connecting (yes/no)? yes
[email protected]'s password:
Welcome to Ubuntu 18.04.2 LTS (GNU/Linux 4.15.0-46-generic x86_64)
我注意到,对于新的部署服务器,PyCharm有时不要求我接受ECDSA密钥指纹。也许这可能会导致PyCharm在等待用户接受从未显示过的指纹提示时不断尝试“通过SFTP连接”。
我不使用KeX算法,因此建议的解决方法here无法使用。
我能够解决问题。日志表明sftp出了点问题。通过调试sftp -v [email protected]
的输出,我可以看到通过SSH进行的身份验证工作正常,但之后sftp将停止。事实证明,我在zsh
中有命令~/.bashrc
,该命令对ssh会话有效,但对sftp会话却无效。从bashrc删除此行,而是使用chsh <user> -s /bin/zsh
解决了该问题,现在已成功启用Connecting by SFTP
。