Reputation: 537
I had set up a single connection to a remote host in VS code and everything was working perfectly. I have access to 2 user accounts (dev
and engineer
) on the same remote host so I tried to set up the 2nd user account also. Unfortunately, this has now broken the initial connection (dev
) whereby the VS code server runs from the engineer
home directory. As dev
does not have access to the engineer
home directory I get an error and VS code will not connect.
I would have thought setting up 2 users to the same remote host was straight forward but maybe this is not possible?
My ssh config file looks like this:
Host gch1
HostName gch1
User engineer
IdentityFile C:\Users\MY_MS_USER\.ssh\id_engineer
Host gch1
HostName gch1
User dev
IdentityFile C:\Users\MY_MS_USER\.ssh\id_ed25519
I had tried to change the Host in the config to dev@gch1
and engineer@gch1
but I was prompted for my password for both users in this case.
Upvotes: 1
Views: 1128
Reputation: 82400
The HOST defines an alias, any choice can be made.
But if you use two times the same alias (two lines with the same HOST ), both blocks will be parsed.
But in the ssh-config each setting can only be set once, the first settings remains in that case.
In your case, the second block can never change anything.
Therefore you need different aliases
Host gch-eng
User engineer
IdentityFile C:\Users\MY_MS_USER\.ssh\id_engineer
Host gch-dev
User dev
IdentityFile C:\Users\MY_MS_USER\.ssh\id_ed25519
# These settings are used for both
Host gch-*
HostName gch1
LocalForward 8080 localhost:8080
Upvotes: 0
Reputation: 91
A workaround would be to start the VS code with one User in the following file. And after establishing first connection, you can start a second VS code connection by changing the "User" field in the following file. Open a Remote Window -> Configure ssh hosts -> c:\Users\myname\.ssh\config
Host gch1
HostName gch1
User engineer
You should only have one "User" for the given hostname in the above file.
Upvotes: 0