通过SFTP连接到PyCharm中的部署服务器不起作用

2024-09-29 23:19:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我已在中配置了带有登录名和密码的SFTP连接 PyCharm 2019.3.3 (Build #PY-193.6494.30)在{}上。当我尝试“测试SFTP连接”时,我没有得到任何错误,但得到了一个“通过SFTP连接”的循环,该循环从未超时。每次我重新安装PyCharm时,它都会工作2-3次,但在那之后,连接就不再建立,我得到了如上所述的连接循环。当我重新安装PyCharm时,我确保从~/Library中删除所有相关文件。正在通过VPN隧道建立连接。我可以完美地ssh到相同的部署地址,只有PyCharm无法连接

enter image description here

我可以从日志中获得以下信息:

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 user@10.5.166.81: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 user@10.5.166.81: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 user@10.5.166.81: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
user@10.5.166.81's password:
Welcome to Ubuntu 18.04.2 LTS (GNU/Linux 4.15.0-46-generic x86_64)

我注意到,对于新部署服务器,PyCharm有时不要求我接受ECDSA密钥指纹。也许这会导致PyCharm无休止地尝试“通过SFTP连接”,同时等待用户接受从未出现的密钥指纹提示

我不使用KeX算法,因此建议的解决方案here无法使用


Tags: todebuginfobynetwithpasswordssh
1条回答
网友
1楼 · 发布于 2024-09-29 23:19:17

我能够解决这个问题。日志表明sftp有问题。通过调试sftp -v user@10.5.166.81的输出,我可以看到通过SSH进行的身份验证工作正常,但sftp将在这之后停止。事实证明,我在~/.bashrc中使用了zsh命令,该命令对ssh会话很有效,但对sftp会话无效。从bashrc中删除这一行并使用chsh <user> -s /bin/zsh解决了问题,现在成功地启用了Connecting by SFTP

相关问题 更多 >

    热门问题