繁体   English   中英

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

[英]Connecting by SFTP to a deployment server in PyCharm does not work

我已在Mac OS 10.15.3上的PyCharm 2019.3.3 (Build #PY-193.6494.30)使用登录名和密码配置 SFTP 连接。 当我尝试“测试 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 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 算法,因此无法使用此处建议的解决方法。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM