一
1 下载VScode
2 安装ssh插件
根据你的操作系统选择对应的版本进行下载和安装。 安装完成之后,启动vscode,选择左侧Extensions 选项卡,在输入框搜索 remote ,选择安装Remote-SSH插件。

安装完成之后会在左侧新增一个选项卡Remote Explorer,如下图所示:

3、添加服务器连接配置
点击该选项卡,会进入SSH TARGETS的添加,如下图所示:

点击添加按钮,输入远程服务器的地址,账号和ip根据自己的情况进行修改,如下图所示:


保存之后,会将刚才的连接信息存储在 C:\Users\chaxun.ssh\config 中

此时就可以在SSH TARGETS中看到添加的远程服务器地址了:

4、连接服务器
右键选择远程服务器,点击Connect to Host in Current Window:



5、基本操作


[图片上传中...(image.png-cd4e69-1701576335922-0)]
点击ok按钮打开 /home/zhaxun 之后,会需要再次输入密码:

如果以上步骤都成功了,那么就会在文件选项卡中看到远程服务器目录下的所有文件了:


删除文件,重命名等操作可以在右键菜单中找到:

当然了,你也可以在terminal中使用shell命令进行操作!
如果下次还想打开远程服务器怎么办?这些信息都会存储在Remote Explorer中,如下图所示,此时只需要右键再次打开即可!

二
Vscode ssh卡死在setting up ssh host
.ssh文件夹权限不足的原因导致
1.找到.ssh文件夹。它通常位于C:\Users,例如C:\Users\Akkuman。
2.右键单击.ssh文件夹,然后单击“属性”。
3.找到并点击“安全”标签。
4.然后单击“高级”。 单击“禁用继承”,单击“确定”。 将出现警告弹出窗口。单击“从此对象中删除所有继承的权限”。
5.你会注意到所有用户都将被删除。让我们添加所有者。在同一窗口中,单击“编辑”按钮。
6.接下来,单击“添加”以显示“选择用户或组”窗口。
7.单击“高级”,然后单击“立即查找”按钮。应显示用户结果列表。 选择您的用户帐户。并赋予全部控制权!
8.然后单击“确定”(大约三次)以关闭所有窗口。
9.完成所有操作后,再次关闭并打开VSCode 并尝试连接到远程SSH主机。
现在这个问题应该解决了。
10.取消只读
三
修改文件显示顺序
code-> perferences->settings
search->explorer.sortOrder
参考链接:https://blog.csdn.net/IT_Holmes/article/details/119364817
vscode连接远程服务器(傻瓜式教学)-CSDN博客
visual-studio-code – 如何更改VS Code的文件排序?_vscode按时间进行排序-CSDN博客
网友评论