2 Star 3 Fork 1

会PS的小码农 / vscode-sftp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

sftp sync extension for VS Code

Paypal Donations PayPal Me

以下内容均为第三方软件翻译

将本地目录与远程服务器目录同步。允许您选择在本地保存文件后编辑将文件上载到远程目录。这允许您或多或少地直接在服务器上编辑类似于winscp或其他类似的程序。

动力很好,功能也很好。非常简单,只需要三行配置!很快,一眨眼就完成了。

使用

如果您的最新文件在服务器上,您可以从一个空的本地文件夹开始,然后下载您的项目,然后从该点同步。

  1. 在“vs code”中,打开要同步到远程服务器的本地目录(或创建一个空目录,您希望首先下载远程服务器文件夹的内容以便在本地进行编辑)。
  2. 在windows/linux上按ctrl+shift+p或在mac open command palette上使用“cmd+shift+p”,运行“sftp:config”命令。
  3. 将出现一个名为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参数是可选的,但是如果不添加它,系统会不断提示您输入密码。请注意,必须用反斜杠转义任何反斜杠和其他特殊字符。

下面还有其他配置示例。

  1. 保存并关闭sftp.json文件文件。
  2. 在windows/linux上为ctrl+shift+p或在mac open命令调色板上为cmd+shift+p
  3. 键入“sftp”,现在您将看到其他一些comand。
  4. 如果您想从远程文件夹开始,最好先是'sftp:download project。这将下载中的“remotepath”设置中显示的目录sftp.json`到您的本地打开目录。
  5. 完成-您现在可以在本地编辑,每次保存后,它将上载到远程文件。
  6. 尽情使用把!

详细用法。请转到 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"]
}

远程资源管理器

remote-explorer-preview

远程资源管理器允许您在远程中浏览文件。您可以通过以下方式打开远程资源管理器:

  1. 运行命令“view:show sftp”。
  2. 单击活动栏中的sftp视图。

只能使用远程资源管理器查看文件内容。运行命令sftp:edit in local以在本地编辑它。 _注意:uu在删除文件后,需要手动刷新父文件夹,以更新资源管理器。

调试

  1. 打开用户设置。

    • Windows/Linux系统 - File > Preferences > Settings
    • macOS系统 - Code > Preferences > Settings
  2. 设置sftp调试设置为“true”并重新加载vscode。

  3. 查看“view>output>sftp”中的日志。


捐赠

如果这个项目帮助你减少了开发时间,你可以给我一杯咖啡:)

微信

Wechat

支付宝

Alipay

PayPal

PayPal PayPal Me

MIT License Copyright (c) 2018-present, Natizyskunk(Natan FOURIÉ) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

github上vscode-sftp的一个分支,我添加了快捷键上传和快捷键下载当前文件功能,修复了传输慢bug 展开 收起
JavaScript 等 2 种语言
MIT
取消

发行版 (1)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/liushuai05/vscode-sftp.git
git@gitee.com:liushuai05/vscode-sftp.git
liushuai05
vscode-sftp
vscode-sftp
master

搜索帮助