In PhpStorm, there is a way to configure multiple SFTP endpoints and chose which server you want to upload to. I'm looking for this functionality in Visual Studio Code. I have installed SFTP VS Code extension and I am able to configure it for one endpoint. What if I want to upload a file to multiple servers? How can I configure that? Or is there another extension that does that?
-
did you try this extension? marketplace.visualstudio.com/… – Charlie Parker Mar 26 '20 at 23:04
-
related issue: github.com/liximomo/vscode-sftp/issues/746 – Charlie Parker Mar 26 '20 at 23:30
There are lot of add-ins that will work for your requirements. Below are a list of few
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
Hi you can add multiple ftp servers to config. Just The context must not be same.
[
{
"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"
}
]
-
1To clarify, the 'context' refers to the path to which the files will be downloaded, and to avoid conflicts with folders/files with the same names in the different folders. Aditionally, the example shows them as absoulte paths, from the root folder
/
, I recommend setting them as relative to your default SFTP folder, e.g../path/to/server1files
– DiegoDD Jul 25 '19 at 23:18 -
1
-
Does this give me the option to upload to one server at a time, or they will sync to both together? – A. Adam Nov 8 '19 at 3:05
-
@DiegoDD you mean "from which the path will be downloaded" or did you mean "from which the path will be uploaded"? – Charlie Parker Mar 26 '20 at 23:04
-
You can use "profiles" with the SFTP extension now. 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"
}
-
can you have individual remote paths rather than one at the top of the project? – Charlie Parker Mar 26 '20 at 23:13
-
also, I want to push to BOTH on save not only 1 one of them, is that possible? – Charlie Parker Mar 26 '20 at 23:15
You can set up remotePath for each of your profiles like that: (I saw that such question was asked by @Charlie Parker in the second answer to that question)
{
"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"
},
}
}
And with Ctrl+Sifht+P > Set Profile you can change your 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"
}
]
Try this:
[ { "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 } ]