VScode使用ssh远程开发,并实现端口转发功能

2024年最全VScode远程连接linux_vscode远程连接linux服务器-CSDN博客

全局安装 yarn npm install -g yarn

有时缓存问题会导致安装变慢,尝试清理缓存:npm cache clean --force

尝试更换镜像源:

npm config set registry https://registry.npm.taobao.org

npm config set registry https://registry.npmmirror.com

如果希望 VS Code 记住已转发的任何端口,请在设置编辑器 (⌘,) 中选中"Remote: Restore Forwarded Ports"或在 settings.json 中设置 "remote.restoreForwardedPorts": true 。

实现在连接时,自动转发端口,可以将以下内容添加到~/.ssh/config文件中

复制代码
# SSH config file
Host remote-linux-machine
    User myuser
    HostName remote-linux-machine.mydomain
    LocalForward 127.0.0.1:3000 127.0.0.1:3000
    LocalForward 127.0.0.1:27017 127.0.0.1:27017
    # 将【remote-linux-machine】服务器中内网的端口转发到本地,并手动配置域名到hosts中,实现通过域名访问服务器内网中的端口
    LocalForward kuboard.intranet.company:30084 172.17.0.2:80

到此就实现了通过端口转发,在本地电脑上访问远程服务器上的内网的服务的功能。

相关推荐
cuijiecheng20183 小时前
Linux下Beyond Compare过期
linux·运维·服务器
期待のcode4 小时前
前后端分离项目 Springboot+vue 在云服务器上的部署
服务器·vue.js·spring boot
AI 智能服务4 小时前
第6课__本地工具调用(文件操作)
服务器·人工智能·windows·php
松涛和鸣7 小时前
49、智能电源箱项目技术栈解析
服务器·c语言·开发语言·http·html·php
凉、介7 小时前
SylixOS 中的 Unix Socket
服务器·c语言·笔记·学习·嵌入式·sylixos
RisunJan7 小时前
Linux命令-ipcs命令(报告进程间通信(IPC)设施状态的实用工具)
linux·运维·服务器
HABuo8 小时前
【Linux进程(四)】进程切换&环境变量深入剖析
linux·运维·服务器·c语言·c++·ubuntu·centos
wzfj123458 小时前
vscode通过remote-ssh快速浏览远程pc的文件
vscode
橘颂TA8 小时前
【Linux】死锁四条件的底层逻辑:从锁冲突到 STL 组件的线程安全实践(Ⅵ)
linux·运维·服务器·c++·死锁