Remote Dev Assistant - VS Code 插件
🚀 自动同步本地文件到远程服务器 + 一键执行远程命令,提升远程开发效率,交叉开发利器,跨平台开发神器!
功能亮点
- 🔄 实时文件同步 - 本地文件修改后自动上传到远程服务器
- ⚡ 一键执行远程命令 - 按
F5 快速运行服务器上的脚本/程序
- 📜 终端输出集成 - 直接在 VS Code 输出面板查看远程执行结果
- 🔒 SSH 密钥支持 - 安全连接,无需频繁输入密码
- 🎛️ 无配置不占用快捷键 - 无配置文件时插件处于静默状态
- 🖥️ 多主机管理 - 支持配置多个 SSH 连接,快速切换
- 📦 压缩同步 - 使用压缩包方式批量同步文件,提升效率
- 🔥 配置热加载 - 保存配置文件后自动生效,无需重启
使用方法
方式一:通过侧边栏图形界面配置(推荐)
打开 Remote Develop 侧边栏
- 点击左侧活动栏的 Remote Develop 图标
添加 SSH 连接
- 在「SSH」视图中点击「添加 SSH 连接」
- 按提示输入:
- 连接显示名称(如:公司测试机)
- SSH 主机名或 IP
- SSH 端口(默认 22)
- SSH 用户名
- 私钥文件路径
- 远程项目根目录(Linux 路径,如
/home/user/project)
- F5 远程启动命令(如
./run.sh)
切换激活的连接
- 在 SSH 列表中右键点击连接,选择「使用」
- 或使用「打开配置」直接编辑 JSON 文件
方式二:手动编辑配置文件
在项目 .vscode/remotedev-hosts.json 中添加服务器信息:
{
"version": 1,
"activeHostId": "host-1",
"hosts": [
{
"id": "host-1",
"name": "公司测试机",
"ssh": {
"host": "192.168.1.10",
"port": 22,
"username": "root",
"privateKeyPath": "~/.ssh/id_rsa",
"passphrase": ""
},
"remoteBasePath": "/home/user/project",
"runCommand": "./build.sh",
"localCommand": "./local-build.cmd",
"localCommand1": "./flash.cmd"
}
]
}
配置文件字段说明
| 字段 |
类型 |
说明 |
version |
number |
配置文件版本,固定为 1 |
activeHostId |
string |
当前激活的连接 ID |
hosts |
array |
SSH 连接配置数组 |
hosts[].id |
string |
连接唯一标识 |
hosts[].name |
string |
连接显示名称 |
hosts[].ssh.host |
string |
远程服务器 IP 或域名 |
hosts[].ssh.port |
number |
SSH 端口,默认 22 |
hosts[].ssh.username |
string |
SSH 登录用户名 |
hosts[].ssh.privateKeyPath |
string |
SSH 私钥文件路径 |
hosts[].ssh.passphrase |
string |
私钥密码(如有) |
hosts[].remoteBasePath |
string |
远程项目根目录 |
hosts[].runCommand |
string |
F5 执行的远程命令 |
hosts[].localCommand |
string |
F6 执行的本地命令(可选) |
hosts[].localCommand1 |
string |
F7 执行的本地命令(可选) |
快捷键
⚡ 命令执行
| 快捷键 |
功能说明 |
配置项 |
F5 |
执行远程命令(如未配置远程主机,则在本地执行) |
runCommand |
F6 |
执行本地主命令 |
localCommand |
F7 |
执行本地备用命令 |
localCommand1 |
注意:快捷键仅在编辑器获得焦点且已配置远程开发时生效。
侧边栏功能
SSH 视图
- 显示所有配置的 SSH 连接
- 当前激活的连接会显示特殊图标
- 支持右键操作:使用、删除
常用操作视图
- 同步文件到远程 - 手动触发文件同步
- 添加 SSH 连接 - 交互式添加新连接
- 打开 remotedev-hosts.json - 直接编辑配置文件
- 刷新连接列表 - 重新加载配置
命令面板
按 Ctrl+Shift+P(或 Cmd+Shift+P)打开命令面板,搜索以下命令:
| 命令 |
说明 |
Remote Develop: 运行远程脚本 (F5) |
执行配置的远程命令 |
Remote Develop: 输入远程命令执行 |
交互式输入远程命令 |
Remote Develop: 编辑 SSH 连接配置 |
打开配置文件 |
Remote Develop: 打开配置 |
打开 remotedev-hosts.json |
Remote Develop: 添加SSH |
交互式添加 SSH 连接 |
Remote Develop: 刷新SSH |
刷新连接列表 |
Remote Develop: 重新加载运行时 |
热加载配置 |
Remote Develop: 同步文件到远程 |
手动同步整个工作区 |
Remote Develop: 同步当前目录到远程 |
同步指定文件夹 |
Remote Develop: 执行本地CMD文件 |
执行 localCommand |
Remote Develop: 执行本地CMD1文件 |
执行 localCommand1 |
文件同步说明
自动同步
- 保存文件时自动触发同步(可在设置中关闭)
- 同步延迟默认为 500 毫秒(可在设置中调整)
手动同步
- 使用命令面板或侧边栏的「同步文件到远程」
- 在资源管理器中右键文件夹选择「同步当前目录到远程」
同步方式
- 压缩同步(默认)- 将文件打包压缩后上传,效率更高
- 逐文件同步 - 压缩同步失败时自动回退到此方式
设置选项
在 VS Code 设置中搜索 Remote Develop:
| 设置项 |
类型 |
默认值 |
说明 |
remoteDevelop.autoSync |
boolean |
true |
是否自动同步文件更改 |
remoteDevelop.syncDelay |
number |
500 |
文件更改后同步延迟(毫秒) |
从旧版本迁移
如果之前使用 .vscode/config.json(单连接配置),插件会自动将其迁移到新的 remotedev-hosts.json 格式。迁移后:
- 原
config.json 保留作为备份
- 自动生成包含单条连接的新配置文件
- 连接名称为「默认(自 config.json 迁移)」
快速开始
1. 安装插件
在 VS Code 扩展商店搜索 "RemoteDev" 并安装。
2. 配置 SSH 连接
- 方式一:通过侧边栏「添加 SSH 连接」交互式配置
- 方式二:手动创建
.vscode/remotedev-hosts.json 文件
3. 开始开发
- 保存文件即可自动同步到远程服务器
- 按
F5 执行远程命令
- 按
F6/F7 执行本地命令
- 在输出面板查看执行结果
支持
如有问题或建议,请访问我们的 GitHub 仓库。
享受无缝远程开发体验! 🎉
Remote Dev Assistant - VS Code Extension
🚀 Automatically sync local files to remote server + one-click remote command execution, boosting remote development efficiency. A must-have tool for cross-development and cross-platform development!
Key Features
- 🔄 Real-time File Sync - Automatically upload modified local files to the remote server
- ⚡ One-click Remote Command Execution - Press
F5 to quickly run scripts/programs on the server
- 📜 Integrated Terminal Output - View remote execution results directly in VS Code's output panel
- 🔒 SSH Key Support - Secure connections without frequent password input
- 🎛️ Zero Config, No Hotkey Occupation - Plugin remains silent when there's no configuration file
- 🖥️ Multi-host Management - Support multiple SSH connections with quick switching
- 📦 Compressed Sync - Batch sync files using compressed archives for better efficiency
- 🔥 Hot Config Reload - Configuration changes take effect immediately without restart
Usage
Open Remote Develop Sidebar
- Click the Remote Develop icon in the left activity bar
Add SSH Connection
- Click "Add SSH Connection" in the "SSH" view
- Enter the following information:
- Connection display name (e.g., "Company Test Server")
- SSH hostname or IP
- SSH port (default 22)
- SSH username
- Private key file path
- Remote project root directory (Linux path, e.g.,
/home/user/project)
- F5 remote startup command (e.g.,
./run.sh)
Switch Active Connection
- Right-click a connection in the SSH list and select "Use"
- Or use "Open Configuration" to edit the JSON file directly
Method 2: Manual Configuration
Add server information to .vscode/remotedev-hosts.json in your project:
{
"version": 1,
"activeHostId": "host-1",
"hosts": [
{
"id": "host-1",
"name": "Company Test Server",
"ssh": {
"host": "192.168.1.10",
"port": 22,
"username": "root",
"privateKeyPath": "~/.ssh/id_rsa",
"passphrase": ""
},
"remoteBasePath": "/home/user/project",
"runCommand": "./build.sh",
"localCommand": "./local-build.cmd",
"localCommand1": "./flash.cmd"
}
]
}
Configuration Fields
| Field |
Type |
Description |
version |
number |
Configuration file version, fixed at 1 |
activeHostId |
string |
ID of the currently active connection |
hosts |
array |
Array of SSH connection configurations |
hosts[].id |
string |
Unique identifier for the connection |
hosts[].name |
string |
Display name for the connection |
hosts[].ssh.host |
string |
Remote server IP or domain |
hosts[].ssh.port |
number |
SSH port, default 22 |
hosts[].ssh.username |
string |
SSH login username |
hosts[].ssh.privateKeyPath |
string |
Path to SSH private key file |
hosts[].ssh.passphrase |
string |
Private key passphrase (if any) |
hosts[].remoteBasePath |
string |
Remote project root directory |
hosts[].runCommand |
string |
Remote command executed with F5 |
hosts[].localCommand |
string |
Local command executed with F6 (optional) |
hosts[].localCommand1 |
string |
Local command executed with F7 (optional) |
Shortcuts
⚡ Command Execution
| Shortcut |
Function |
Configuration |
F5 |
Execute remote command (or local if no remote host configured) |
runCommand |
F6 |
Execute local primary command |
localCommand |
F7 |
Execute local alternative command |
localCommand1 |
Note: Shortcuts only work when the editor has focus and remote development is configured.
SSH View
- Display all configured SSH connections
- Currently active connection shows a special icon
- Right-click operations: Use, Delete
Quick Actions View
- Sync Files to Remote - Manually trigger file sync
- Add SSH Connection - Interactively add new connection
- Open remotedev-hosts.json - Edit configuration file directly
- Refresh Connection List - Reload configuration
Command Palette
Press Ctrl+Shift+P (or Cmd+Shift+P) to open the command palette and search for:
| Command |
Description |
Remote Develop: Run Remote Script (F5) |
Execute configured remote command |
Remote Develop: Enter Remote Command |
Interactively enter remote command |
Remote Develop: Edit SSH Connection Config |
Open configuration file |
Remote Develop: Open Configuration |
Open remotedev-hosts.json |
Remote Develop: Add SSH |
Interactively add SSH connection |
Remote Develop: Refresh SSH |
Refresh connection list |
Remote Develop: Reload Runtime |
Hot reload configuration |
Remote Develop: Sync Files to Remote |
Manually sync entire workspace |
Remote Develop: Sync Current Folder to Remote |
Sync specified folder |
Remote Develop: Execute Local CMD File |
Execute localCommand |
Remote Develop: Execute Local CMD1 File |
Execute localCommand1 |
File Sync
Auto Sync
- Automatically triggered when saving files (can be disabled in settings)
- Default sync delay is 500 milliseconds (adjustable in settings)
Manual Sync
- Use command palette or sidebar "Sync Files to Remote"
- Right-click folder in explorer and select "Sync Current Folder to Remote"
Sync Methods
- Compressed Sync (default) - Package and compress files before uploading, more efficient
- File-by-file Sync - Fallback when compressed sync fails
Settings
Search for Remote Develop in VS Code settings:
| Setting |
Type |
Default |
Description |
remoteDevelop.autoSync |
boolean |
true |
Whether to auto sync file changes |
remoteDevelop.syncDelay |
number |
500 |
Delay before syncing after file change (ms) |
Migration from Old Versions
If you previously used .vscode/config.json (single connection config), the plugin will automatically migrate it to the new remotedev-hosts.json format. After migration:
- Original
config.json is kept as backup
- New configuration file with single connection is generated automatically
- Connection name will be "Default (migrated from config.json)"
Quick Start
1. Install the Extension
Search for "RemoteDev" in the VS Code extension marketplace and install it.
- Method 1: Use "Add SSH Connection" in the sidebar
- Method 2: Manually create
.vscode/remotedev-hosts.json file
3. Start Development
- Save any file to trigger automatic sync to the remote server
- Press
F5 to execute the remote command
- Press
F6/F7 to execute local commands
- View execution results in the output panel
Support
For issues and suggestions, please visit our GitHub Repository.
Enjoy seamless remote development! 🎉