VSCode连接远程服务器

VSCode下载安装包VSCode-win32-x64-1.70.1.zip

【配置文件】

launch.json

javascript 复制代码
{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) 启动",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/AlgoOnline",
            "args": [
                "-d",
                "-c", "/data/peizhiwenjianConfig.xml",
                // "-r", "/data/....
                // "-C","",

            ],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "gdb",
            "preLaunchTask": "compile",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "将反汇编风格设置为 Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

settings.json

javascript 复制代码
{
    "gotoSymbolStack.currentStackPosition": 0,
    "gotoSymbolStack.maxStackPosition": 0,
    "gotoSymbolStack.filePositionInfo": [],
    "files.associations": {
        "qbytearray": "cpp",
        "quuid": "cpp",
        "*.tcc": "cpp",
        "iosfwd": "cpp",
        "fstream": "cpp",
        "istream": "cpp",
        "cctype": "cpp",
        "clocale": "cpp",
        "cmath": "cpp",
        "cstdarg": "cpp",
        "cstddef": "cpp",
        "cstdio": "cpp",
        "cstdlib": "cpp",
        "cstring": "cpp",
        "ctime": "cpp",
        "cwchar": "cpp",
        "cwctype": "cpp",
        "array": "cpp",
        "atomic": "cpp",
        "strstream": "cpp",
        "bitset": "cpp",
        "chrono": "cpp",
        "complex": "cpp",
        "condition_variable": "cpp",
        "cstdint": "cpp",
        "deque": "cpp",
        "list": "cpp",
        "unordered_map": "cpp",
        "vector": "cpp",
        "exception": "cpp",
        "functional": "cpp",
        "initializer_list": "cpp",
        "iomanip": "cpp",
        "iostream": "cpp",
        "limits": "cpp",
        "mutex": "cpp",
        "new": "cpp",
        "ostream": "cpp",
        "numeric": "cpp",
        "ratio": "cpp",
        "sstream": "cpp",
        "stdexcept": "cpp",
        "streambuf": "cpp",
        "system_error": "cpp",
        "thread": "cpp",
        "cfenv": "cpp",
        "cinttypes": "cpp",
        "tuple": "cpp",
        "type_traits": "cpp",
        "utility": "cpp",
        "typeindex": "cpp",
        "typeinfo": "cpp",
        "memory": "cpp",
        "future": "cpp",
        "ranges": "cpp",
        "variant": "cpp",
        "bit": "cpp",
        "charconv": "cpp",
        "codecvt": "cpp",
        "compare": "cpp",
        "concepts": "cpp",
        "forward_list": "cpp",
        "map": "cpp",
        "set": "cpp",
        "unordered_set": "cpp",
        "algorithm": "cpp",
        "iterator": "cpp",
        "memory_resource": "cpp",
        "optional": "cpp",
        "random": "cpp",
        "regex": "cpp",
        "string": "cpp",
        "string_view": "cpp",
        "span": "cpp",
        "stop_token": "cpp",
        "valarray": "cpp",
        "cassert": "cpp",
        "qvariant": "cpp",
        "qvector": "cpp",
        "qdatetime": "cpp",
        "shared_mutex": "cpp",
        "*.ipp": "cpp",
        "csignal": "cpp"
    },
    "workbench.colorCustomizations": {
        "activityBar.activeBackground": "#61adfa",
        "activityBar.background": "#61adfa",
        "activityBar.foreground": "#15202b",
        "activityBar.inactiveForeground": "#15202b99",
        "activityBarBadge.background": "#bf0060",
        "activityBarBadge.foreground": "#e7e7e7",
        "commandCenter.border": "#e7e7e799",
        "sash.hoverBorder": "#61adfa",
        "statusBar.background": "#61adfa",
        "statusBar.foreground": "#e7e7e7",
        "statusBarItem.hoverBackground": "#61adfa",
        "statusBarItem.remoteBackground": "#61adfa",
        "statusBarItem.remoteForeground": "#e7e7e7",
        "titleBar.activeBackground": "#61adfa",
        "titleBar.activeForeground": "#e7e7e7",
        "titleBar.inactiveBackground": "#61adfa99",
        "titleBar.inactiveForeground": "#e7e7e799"
    },
    "peacock.remoteColor": "#61adfa"
}

tasks.json

javascript 复制代码
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            // "command": "C:\\Program Files\\CMake\\bin\\cmake.exe",
            "command": "make",
            "args": [],
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        },
        {
            "label": "compile",
            "type": "shell",
            "command": "make",
            "args": ["compile"],
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

【将Linux服务器项目在VSCode内运行SOP】

1、首先使用ssh命令连接远程服务器

bash 复制代码
ssh [选项] 远程用户@远程主机地址

顺带提一嘴,和这个SOP无关

bash 复制代码
# 本地文件上传到服务器
scp /local/path/file.txt root@192.168.1.100:/remote/path/
 
# 服务器文件下载到本地
scp root@192.168.1.100:/remote/path/file.txt /local/path/

VSCode左下角选择Connect Current Windows to Host -> Add New SSH Host... -> 输入ssh命令

ssh hello@microsoft.com-A

输入完之后选择第一个选项C:\Users\user\.ssh\config,打开config选项,关闭config文件(config内有远程服务器Host HostName User)

重新点击左下角 -> Connect Current Windows to Host -> Linux-> 输入密码 -> 进入VSCode欢迎页

点击菜单栏文件 -> 打开文件夹 -> 选择项目所在的文件夹 -> 输入密码

【删除连接的服务器】

重新点击左下角 -> Open SSH Configuration File ... -> 选择第一个选项C:\Users\user\.ssh\config

删除文件内对应的Host HostName User参数

2、​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​在VSCode新开一个Terminal

在项目所在的文件夹内操作,使用ln命令,将项目生成的二进制文件软连接到该文件夹

bash 复制代码
ln -s ../build/ebi-debug/Applications/AlgoOnline ./

目的是为了与launch.json内的这一块对应

javascript 复制代码
configurations": [
        {
            "name": "(gdb) 启动",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/AlgoOnline",
            "args": [
                "-d",
                "-c", "/data/gaoqian/workdir/beegfs/hunter/etc/AlgoConfig.xml",
                // "-r", "/data/donghong.li/workspace/beegfs/inspection/recipe-20241231-182723/",
                // "-C","",

            ],

在该文件夹./内就会出现一个软链接,ll命令查看显示为AlgoOnline -> ../build/ebi-debug/Applications/AlgoOnline

ll 文件路径/文件名称

可以查看文件的详细信息

......持续补充中


------2025.12.16

还好有大神助我,抓紧时间记录下来

我要一雪前耻

https://blog.csdn.net/yan_lai/article/details/146398935?spm=1001.2014.3001.5502

相关推荐
Ydwlcloud2 小时前
AWS国际版新账号注册隐藏优惠全解析:2026年实测避坑指南
大数据·服务器·人工智能·云计算·aws
小李独爱秋2 小时前
计算机网络经典问题透视——搜索引擎的“两大门派”与“武林新秀”
服务器·网络·网络协议·tcp/ip·计算机网络·搜索引擎
祁思妙想2 小时前
修改python后端项目名称:pycharm中fastapi框架的项目
ide·pycharm·fastapi
Yue丶越2 小时前
【C语言】文件操作
服务器·c语言·开发语言
笙枫2 小时前
Agent 进阶设计:状态管理、中间件与多Agent协作
java·服务器·python·ai·中间件
YJlio2 小时前
Disk2vhd 学习笔记(13.1):在线 VHD 冷备份与迁移实战
服务器·笔记·学习
huxiaoxiao.2 小时前
使用webStorm或idea将一个项目的变更合并至另一个项目
ide·webstorm
路由侠内网穿透.2 小时前
本地部署远程服务管理软件 IntelliSSH 并实现外部访问
运维·服务器·网络·网络协议
同聘云2 小时前
阿里云国际站服务器防火墙怎么关闭?防火墙部署方式有哪些?
服务器·阿里云·云计算