VS code Insiders Remote SSH连接问题

(本文参考Remote Development Tips and Tricks)

环境:win10+VS Code Insiders+OpenSSH
问题:用VScode Remote SSH远程连接时会卡在这里:
VS code Insiders Remote SSH连接问题_第1张图片
原因:需要生成ssh公钥
方法1:生成一个默认的公钥文件

1.检查公钥文件%USERPROFILE%\.ssh\id_rsa.pub是否存在。

2.如果不存在,输入以下命令生成公钥文件:

ssh-keygen -t rsa -b 4096

3.输入以下命令:

SET REMOTEHOST=your-user-name-on-host@host-fqdn-or-ip-goes-here
	
scp %USERPROFILE%\.ssh\id_rsa.pub %REMOTEHOST%:~/tmp.pub
ssh %REMOTEHOST% "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat ~/tmp.pub >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys && rm -f ~/tmp.pub"

方法2:生成一个指定的公钥文件
1.输入以下命令:

ssh-keygen -t rsa -b 4096 -f %USERPROFILE%\.ssh\id_rsa-remote-ssh

SET REMOTEHOST=name-of-ssh-host-here
SET PATHOFIDENTITYFILE=%USERPROFILE%\.ssh\id_rsa-remote-ssh.pub

scp %PATHOFIDENTITYFILE% %REMOTEHOST%:~/tmp.pub
ssh %REMOTEHOST% "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat ~/tmp.pub >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys && rm -f ~/tmp.pub"

2.在ssh配置文件中加入该公钥(在VS Code中执行Remote-SSH: Open Configuration File…)

Host name-of-ssh-host-here
    User your-user-name-on-host
    HostName host-fqdn-or-ip-goes-here
    IdentityFile ~/.ssh/id_rsa-remote-ssh

结果:采用这个方法配置完之后,一些Linux机器能够正常连接了。但是又出现了新的问题,在连接某些Linux服务器的时候,提示如下错误:
VS code Insiders Remote SSH连接问题_第2张图片目前还未找到解决办法。

你可能感兴趣的:(editor,/,IDE)