随笔 - 100  文章 - 0  评论 - 6  阅读 - 88973

VSCode使用sftp自动同步代码到远端服务器

VSCode 修改代码后,使用SFTP插件自动同步到远端服务器

1.安装SFTP插件

2.SFTP配置

  • 在通过VSCode打开的文件夹下有一个 .vscode的文件夹,在下面新建一个sftp.json,SFTP插件会根据这个json里面的配置做动作

** sftp.json **

[
    {
        "name": "caevs",
		"protocol": "sftp",
        "port": 22,
        "host": "10.1.1.27",        
        "username": "dell",
		"password": "Admin@123",
        "remotePath": "/home/dell/ldq_code/buildsystem/android11/caevs",
        "uploadOnSave": true,
        "useTempFile": false,        
        "openSsh": false,
        "watcher": {
            "files": "**/*",
            "autoUpload": true,
            "autoDelete": true
        },
        "ignore": [
            "**/.vscode/**",
            "**/.git/**",
            "**/build/**"
        ]
    }
]

** 参数说明 **

[
    {
        "name": "caevs",
		"protocol": "sftp",    //同步文件使用的协议
        "port": 22, 
        "host": "10.1.1.27",       //远端服务器IP                  
        "username": "dell",       //登录远端服务器的用户名
		"password": "Admin@123",  //密码
        "remotePath": "/home/dell/ldq_code/buildsystem/android11/caevs", //远端服务器路径,上传的文件会以此路径为根目录
        "uploadOnSave": true,     //保存文件时,自动上传
        "useTempFile": false,        
        "openSsh": false,
        "watcher": {	           //监听files指定目录下的文件
            "files": "**/*",
            "autoUpload": true,    //改变时自动上传
            "autoDelete": true     //删除时,自动删除远端
        },
        "ignore": [               //忽略这些目录下的改变
            "**/.vscode/**",
            "**/.git/**",
            "**/build/**"
        ]
    }
]

补充说明

  • 同时配置多个服务器
{
    "name": "My Server",
    "protocol": "sftp",
    "port": 22,
    "profiles": {
        "android_dell": {
            "host": "10.63.1.27",
            "username": "dell",
            "remotePath": "/home/dell/ldq_code/buildsystem/android11/caevs",
            "password": "Admin@123"
        },
        "android8155": {
            "host": "10.63.1.33",
            "username": "liuyy",
            "remotePath": "/u01/liuyy/Work/LYY/AOSP/8155user/caevs",
            "password": "Evs2021!"
        }
    },
    "defaultProfile": "android_dell",
    "uploadOnSave": true,
    "useTempFile": false,
    "openSsh": false,
    "ignore": [
        ".vscode",
        ".git",
        ".DS_Store",
        "files\\external"
    ],
    "watcher": {
        "files": "**/*",
        "autoUpload": true,
        "autoDelete": true
    }
}
posted on   林西索  阅读(1606)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
· 使用C#创建一个MCP客户端
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示