Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support $HOME environment variable in "remote.SSH.configFile" #1146

Closed
rcdailey opened this issue Aug 12, 2019 · 9 comments
Closed

Support $HOME environment variable in "remote.SSH.configFile" #1146

rcdailey opened this issue Aug 12, 2019 · 9 comments
Assignees
Labels
feature-request Request for new features or functionality *out-of-scope Posted issue is not in scope of VS Code ssh Issue in vscode-remote SSH

Comments

@rcdailey
Copy link

rcdailey commented Aug 12, 2019

  • VSCode Version: 1.37
  • Local OS Version: Windows 10
  • Remote OS Version: N/A
  • Remote Extension/Connection Type: SSH

On my machine, I have a HOME environment variable set which points to my linux home directory (this is mostly for Git Bash):

HOME=C:\Development\Home

I want the SSH Remote extension to use this path to find my ~/.ssh/config file, which does exist. However, it doesn't offer that in the list (it treats ~ as C:\users\myname). I tried to set the setting like so:

"remote.SSH.configFile": "${env:HOME}/.ssh/config"

Which should resolve to C:\Development\Home\.ssh\config, but it doesn't seem to recognize it. I think maybe environment variable support is lacking in this specific setting. I get this error:

ENOENT: no such file or directory, mkdir 'C:\Program Files\Microsoft VS Code\${env:HOME}'

How can I get the Remote SSH extension to recognize and use my .ssh/config in a cross-platform way? I sync my HOME directory as well as my VS Code settings across my work machines. I have my HOME path set differently on each machine. So it's important to be able to configure this extension to find my hosts, keys, and other configuration consistently across these platforms.

@roblourens roblourens self-assigned this Aug 16, 2019
@roblourens roblourens added feature-request Request for new features or functionality ssh Issue in vscode-remote SSH labels Aug 16, 2019
@roblourens
Copy link
Member

We use node's os.homedir() which uses the USERPROFILE variable. Sounds like you have a different sort of setup but it's a fair request. https://nodejs.org/api/os.html#os_os_homedir

@rcdailey
Copy link
Author

@roblourens I've been thinking about this for a while, but why does Remote SSH use ~/.ssh and private key files? Why not just have some JSON configuration where you place the keys instead? SSH client doesn't work very well on Windows. Even the Windows version of SSH. I get lots of UNPROTECTED PRIVATE KEY FILE errors. Yes, I did follow the instructions to fix permissions but my key structure is unique, so the out-of-the-box command you provide in your documentation doesn't work for me.

If configuration was in JSON settings, there would be no permission concerns. You could also make SSH work with hardware security keys without crazy hacks. Everything about this extension is just difficult to use because it feels like Remote SSH is trying to bastardize SSH to work on Windows when it was designed for Linux.

The reality is, permission requirements on Windows are less intuitive compared to linux. On linux, it's a straightforward matter of chmod. But on Windows, it's far more complex.

@roblourens
Copy link
Member

Permissions concerns would still be there, you would just be moving them to a different file. This seems like a comment about ssh on windows, not the ssh extension. We are just invoking whatever ssh binary is present.

@rcdailey
Copy link
Author

Right but it wouldn't be the SSH executable checking and enforcing those permissions since the configuration would then be managed by the extension itself. Somehow the SSHFS extension does this and it works much better IMHO.

I did try the Git for Windows ssh.exe and it works immensely better than the Windows version of SSH. Not sure why. The Git version of SSH doesn't care about file permission on Windows (and rightfully so for the reasons I explained).

@roblourens
Copy link
Member

The sshfs extension doesn't use ssh.exe at all and has made some different design decisions which make sense for their case, but not ours.

@roblourens roblourens added the *out-of-scope Posted issue is not in scope of VS Code label Nov 9, 2020
@rcdailey
Copy link
Author

rcdailey commented Nov 9, 2020

Why was this marked "out of scope"? On 8/15/2019 you said:

it's a fair request

@ejouellette
Copy link

ejouellette commented Mar 14, 2022

I also think that supporting $HOME environment variable in "remote.SSH.configFile" is a great idea!
Or ${env:} or even ${command:} to run arbitrary tasks.

I'm setting up a multi-user build environment on a remote Windows VM, and having this feature would really help simplify per user configuration.
Would it be please be possible to re-open this request?
Thanks!

@akarasulu
Copy link

akarasulu commented May 26, 2022

I just notice that environment variables in the ssh config file are not honored. At least with ssh-config file env variables, we could have gotten around this problem using openssh v8.4 and above. I agree with @2Torr that this is a huge need beyond the textbook use case.

The cited reason for closing it is tangential to the core problem. Please reconsider reopening this issue. Thanks in advance.

@glass-ships
Copy link

glass-ships commented Nov 28, 2024

+1 to consider re-opening.
Semi-related to microsoft/vscode#2809
Would be nice to set:
"remote.SSH.configFile": "$HOME/.ssh/config",
or similar, and have it search %USERPROFILE% on Windows or /home/username on Unix platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality *out-of-scope Posted issue is not in scope of VS Code ssh Issue in vscode-remote SSH
Projects
None yet
Development

No branches or pull requests

5 participants