Visual Studio 代码 SFTP 到多个服务器
Visual Studio Code SFTP to multiple servers
在 PhpStorm 中,有一种方法可以配置多个 SFTP 端点并选择要上传到的服务器。我正在 Visual Studio 代码中寻找此功能。我已经安装了 SFTP VS Code extension,并且能够为一个端点配置它。如果我想将一个文件上传到多个服务器怎么办?我该如何配置?或者是否有其他扩展程序可以做到这一点?
有很多插件可以满足您的要求。下面列出了一些
https://marketplace.visualstudio.com/items?itemName=mkloubert.vs-deploy
https://marketplace.visualstudio.com/items?itemName=mkloubert.vscode-deploy-reloaded
https://marketplace.visualstudio.com/items?itemName=humy2833.ftp-simple
您好,您可以将多个 ftp 服务器添加到配置中。只是 context 不能相同。
[
{
"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"
}
]
您现在可以使用 "profiles" 和 SFTP 扩展。 https://github.com/liximomo/vscode-sftp#profiles
{
"name": "My Project",
"protocol": "sftp",
"remotePath": "/",
"port": 22,
"profiles": {
"dev": {
"host": "server1.example.com",
"username": "username",
"password": "password"
},
"prod": {
"host": "server2.example.com",
"username": "other-username",
"password": "other-password"
}
},
"defaultProfile": "dev"
}
[
{
"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"
}
]
您可以像这样为您的每个配置文件设置 remotePath:(我看到@Charlie Parker 在该问题的第二个答案中提出了这样的问题)
{
"name": "ExampleName",
"protocol": "sftp",
"port": 22,
"profiles": {
"profile1": {
"host": "connection1",
"username": "user1",
"remotePath":"/path1"
},
"profile2": {
"host": "connection2",
"username": "user2",
"remotePath":"/path2"
},
"profile3": {
"host": "connection3",
"username": "user3",
"remotePath":"/path3"
},
}
}
使用 Ctrl+Sifht+P > 设置配置文件,您可以更改您的配置文件。
试试这个:
[
{
"name": "project 1",
"context": "/project/project1",
"host": "",
"username": "",
"password": "",
"protocol": "ftp",
"post": 21,
"remotePath": "/",
"uploadOnSave": true
},
{
"name": "project 2",
"context": "/project/project2",
"host": "",
"username": "",
"password": "",
"protocol": "ftp",
"post": 21,
"remotePath": "/",
"uploadOnSave": true
}
]
在 PhpStorm 中,有一种方法可以配置多个 SFTP 端点并选择要上传到的服务器。我正在 Visual Studio 代码中寻找此功能。我已经安装了 SFTP VS Code extension,并且能够为一个端点配置它。如果我想将一个文件上传到多个服务器怎么办?我该如何配置?或者是否有其他扩展程序可以做到这一点?
有很多插件可以满足您的要求。下面列出了一些
https://marketplace.visualstudio.com/items?itemName=mkloubert.vs-deploy
https://marketplace.visualstudio.com/items?itemName=mkloubert.vscode-deploy-reloaded
https://marketplace.visualstudio.com/items?itemName=humy2833.ftp-simple
您好,您可以将多个 ftp 服务器添加到配置中。只是 context 不能相同。
[
{
"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"
}
]
您现在可以使用 "profiles" 和 SFTP 扩展。 https://github.com/liximomo/vscode-sftp#profiles
{
"name": "My Project",
"protocol": "sftp",
"remotePath": "/",
"port": 22,
"profiles": {
"dev": {
"host": "server1.example.com",
"username": "username",
"password": "password"
},
"prod": {
"host": "server2.example.com",
"username": "other-username",
"password": "other-password"
}
},
"defaultProfile": "dev"
}
[
{
"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"
}
]
您可以像这样为您的每个配置文件设置 remotePath:(我看到@Charlie Parker 在该问题的第二个答案中提出了这样的问题)
{
"name": "ExampleName",
"protocol": "sftp",
"port": 22,
"profiles": {
"profile1": {
"host": "connection1",
"username": "user1",
"remotePath":"/path1"
},
"profile2": {
"host": "connection2",
"username": "user2",
"remotePath":"/path2"
},
"profile3": {
"host": "connection3",
"username": "user3",
"remotePath":"/path3"
},
}
}
使用 Ctrl+Sifht+P > 设置配置文件,您可以更改您的配置文件。
试试这个:
[ { "name": "project 1", "context": "/project/project1", "host": "", "username": "", "password": "", "protocol": "ftp", "post": 21, "remotePath": "/", "uploadOnSave": true }, { "name": "project 2", "context": "/project/project2", "host": "", "username": "", "password": "", "protocol": "ftp", "post": 21, "remotePath": "/", "uploadOnSave": true } ]