将本地目录与远程服务器目录同步。允许您选择在本地保存文件后编辑将文件上载到远程目录。这允许您或多或少地直接在服务器上编辑类似于winscp或其他类似的程序。
动力很好,功能也很好。非常简单,只需要三行配置!很快,一眨眼就完成了。
如果您的最新文件在服务器上,您可以从一个空的本地文件夹开始,然后下载您的项目,然后从该点同步。
在windows/linux上按ctrl+shift+p
或在mac open command palette上使用“cmd+shift+p”,运行“sftp:config”命令。sftp.json文件
在“.vscode”目录下。编辑参数以匹配您的设置。例如:
{
"name": "Profile Name",
"host": "name_of_remote_host",
"protocol": "ftp",
"port": 21,
"secure": true,
"username": "username",
"remotePath": "/public_html/project", <---- This is the path which will be downloaded if you "Download Project"
"password": "password",
"uploadOnSave": true
}
password参数是可选的,但是如果不添加它,系统会不断提示您输入密码。请注意,必须用反斜杠转义任何反斜杠和其他特殊字符。
下面还有其他配置示例。
sftp.json文件
文件。在windows/linux上为ctrl+shift+p
或在mac open命令调色板上为cmd+shift+p
。。这将下载中的“remotepath”设置中显示的目录
sftp.json`到您的本地打开目录。详细用法。请转到 wiki.
你可以在这里看到完整的配置 here.
{
"host": "host",
"username": "username",
"remotePath": "/remote/workspace"
}
{
"username": "username",
"password": "password",
"remotePath": "/remote/workspace/a",
"watcher": {
"files": "dist/*.{js,css}",
"autoUpload": false,
"autoDelete": false
},
"profiles": {
"dev": {
"host": "dev-host",
"remotePath": "/dev",
"uploadOnSave": true
},
"prod": {
"host": "prod-host",
"remotePath": "/prod"
}
},
"defaultProfile": "dev"
}
_注意:只有在根级别才能使用“context”和“watcher”。
使用“sftp:set profile”切换配置文件。
上下文配置必须不相同。
[
{
"name": "server1",
"context": "project/build",
"host": "host",
"username": "username",
"password": "password",
"remotePath": "/remote/project/build"
},
{
"name": "server2",
"context": "project/src",
"host": "host",
"username": "username",
"password": "password",
"remotePath": "/remote/project/src"
}
]
_注意:此模式下需要使用“name”。
您可以通过带有ssh协议的代理连接到目标服务器。 _注意:变量替换在跃点配置中不起作用**
local -> hop -> target
{
"name": "target",
"remotePath": "/path/in/target",
// hop
"host": "hopHost",
"username": "hopUsername",
"privateKeyPath": "/Users/localUser/.ssh/id_rsa", // The key file is assumed on the local.
"hop": {
// target
"host": "targetHost",
"username": "targetUsername",
"privateKeyPath": "/Users/hopUser/.ssh/id_rsa", // The key file is assumed on the hop.
}
}
local -> hopa -> hopb -> target
{
"name": "target",
"remotePath": "/path/in/target",
// hopa
"host": "hopAHost",
"username": "hopAUsername",
"privateKeyPath": "/Users/hopAUsername/.ssh/id_rsa" // The key file is assumed on the local.
"hop": [
// hopb
{
"host": "hopBHost",
"username": "hopBUsername",
"privateKeyPath": "/Users/hopaUser/.ssh/id_rsa" // The key file is assumed on the hopa.
},
// target
{
"host": "targetHost",
"username": "targetUsername",
"privateKeyPath": "/Users/hopbUser/.ssh/id_rsa", // The key file is assumed on the hopb.
}
]
}
可以使用“remote”告诉sftp从[remote fs]获取配置(https://github.com/liximomo/vscode-remote-fs). 在用户设置中:
"remotefs.remote": {
"dev": {
"scheme": "sftp",
"host": "host",
"username": "username",
"rootPath": "/path/to/somewhere"
},
"projectX": {
"scheme": "sftp",
"host": "host",
"username": "username",
"privateKeyPath": "/Users/xx/.ssh/id_rsa",
"rootPath": "/home/foo/some/projectx"
}
}
In sftp.json:
{
"remote": "dev",
"remotePath": "/home/xx/",
"uploadOnSave": true,
"ignore": [".vscode", ".git", ".DS_Store"]
}
远程资源管理器允许您在远程中浏览文件。您可以通过以下方式打开远程资源管理器:
只能使用远程资源管理器查看文件内容。运行命令sftp:edit in local
以在本地编辑它。
_注意:uu在删除文件后,需要手动刷新父文件夹,以更新资源管理器。
打开用户设置。
File > Preferences > Settings
Code > Preferences > Settings
设置sftp调试
设置为“true”并重新加载vscode。
查看“view>output>sftp”中的日志。
如果这个项目帮助你减少了开发时间,你可以给我一杯咖啡:)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型