You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feature-request: New-PSSession -HostName should be able to use the system's ssh-agent to get the required keys. #6207
It'd be nice if we could use SSH PSRemote sessions with our configured session ssh-agent-compatible daemon to get the required security information/
For instance, I use gpg-agent to store my SSH private key securely on my Yubikey 4, as a result my key doesn't actually exist on my laptop.
From looking at the output of ps while New-PSSession is run, it appears you guys are shelling out to ssh anyway, and the ssh client supports the ssh-agent by default, so I assume something is being done to disable it for the invocation.
The idea is to let SSH handle the connection/transport for PS remoting. I don't know what the mechanism is for SSH to work with ssh-agent but PowerShell shouldn't get in the way. More details and repro steps can help determine if PowerShell is preventing this. We may have to update PowerShell code to support this, if possible.
Any chance this can be bumped into 6.1.0? It's somewhat inconvient to be unable to use my securely-stored private key, instead having to use a password.
I know Paul Higinbotham (@PaulHigin) is currently busy with some other work, but this seems like something that shouldn't be too complicated to fix, so I'll leave it to Paul to address when he's able to
Paul Higinbotham (@PaulHigin) I'm not sure what you mean by "parent process" I mentioned in an edit above that at the very least the powershell commandline knows of the auth socket, through $env:SSH_AUTH_SOCK -- the only env variable that my test script above is showing is PWD which is pointed to the directory containing the test ssh command script
I just checked the code, and while I'm not that familiar with C# -- this looks like where the startInfo is coming from? I'm not sure why that would have it's own copy of the parent's environment.
By parent process I mean the command line PowerShell process you are using to create a remote session. I assumed that the default StartInfo environment variables were obtained from the process in which it is currently running. My limited testing seemed to indicate that this was so, but maybe not since your $env:SSH_AUTH_SOCK setting doesn't seem to be propagating. I'll need to take a closer look.
I found some time to look at this some more and I can verify that StartInfo does indeed contain the parent process environment variables, including SSH_AUTH_SOCK, and that they are being passed into the ssh process used for the connection and transport. So there must be something else that prevents ssh-agent from working.
I'll play around with ssh-agent to see if I can repro the problem.
I'm confused about something here. The ssh-agent that comes with Git for Windows will create/use those env vars. But AFAICT, the ssh-agent that comes with OpenSSH (Windows 10 1803), it doesn't create or need those env vars.
I verified that the ssh process created by PowerShell remoting does not have the environment variables, by looking at the virtual file location /proc/[procid]/environ. It seems that our process creation code is not passing in the environment information correctly. I look deeper when I get some time.
My apologies. I was testing the old build without my fix and this is why I didn't see any environment variables. When I test a build with my fix I do now see the environment variables in the ssh process, including SSH_AUTH_SOCK. Next I'll see if I can get ssh-agent working.
Okay, I just re-ran the powershell daily download just now, and when
testing I wasn't asked for my password when sshing into something, so I
expect that I juts managed to get an older nightly when I installed it
earlier? Appologies for the false alarm on it being broken still. :\
On Thu, Jul 12, 2018 at 2:37 PM Paul Higinbotham ***@***.***> wrote:
My apologies. I was testing the old build without my fix and this is why I
didn't see any environment variables. When I test a build with my fix I do
now see the environment variables in the ssh process, including
SSH_AUTH_SOCK. Next I'll see if I can get ssh-agent working.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6207 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAG_ztvgjwvi04CY-dE2z_viEoSGOCp7ks5uF5dZgaJpZM4SN8Ps>
.
Activity
iSazonov commentedon Feb 21, 2018
/cc Paul Higinbotham (@PaulHigin) Could you please comment the feature request.
PaulHigin commentedon Feb 21, 2018
The idea is to let SSH handle the connection/transport for PS remoting. I don't know what the mechanism is for SSH to work with ssh-agent but PowerShell shouldn't get in the way. More details and repro steps can help determine if PowerShell is preventing this. We may have to update PowerShell code to support this, if possible.
AmandaCameron commentedon Feb 22, 2018
A quick test just confirmed what I thought might be the issue -- the
environment variables are being stripped by the time
sshis shelled outto.
ssh uses the environment variable
SSH_AUTH_SOCKto know where the unixsocket for the ssh-agent is, so at least that needs to be preserved.
I tested this with the following shell script placed in my $PATH before the
normal location of ssh:
PaulHigin commentedon Feb 26, 2018
Yes, this looks like a bug in PowerShell when forking the ssh process. It is passing in an empty string array for the environment variables.
https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs#L2148
I'll change this to a bug issue.
AmandaCameron commentedon May 27, 2018
Any chance this can be bumped into 6.1.0? It's somewhat inconvient to be unable to use my securely-stored private key, instead having to use a password.
PaulHigin commentedon May 30, 2018
SteveL-MSFT commentedon May 30, 2018
Amanda Cameron (@AmandaCameron)
6.1.0-Considermeans we're considering it for 6.1.0 alreadyI know Paul Higinbotham (@PaulHigin) is currently busy with some other work, but this seems like something that shouldn't be too complicated to fix, so I'll leave it to Paul to address when he's able to
PaulHigin commentedon May 31, 2018
Ok, I'll look at a fix for 6.1.0 timeframe.
Added copy env vars from ProcessStartInfo to key/pair array used in c…
12 remaining items
AmandaCameron commentedon Jun 26, 2018
Paul Higinbotham (@PaulHigin) I'm not sure what you mean by "parent process" I mentioned in an edit above that at the very least the powershell commandline knows of the auth socket, through
$env:SSH_AUTH_SOCK-- the only env variable that my test script above is showing isPWDwhich is pointed to the directory containing the testsshcommand scriptAmandaCameron commentedon Jun 26, 2018
I just checked the code, and while I'm not that familiar with C# -- this looks like where the startInfo is coming from? I'm not sure why that would have it's own copy of the parent's environment.
PaulHigin commentedon Jun 26, 2018
By parent process I mean the command line PowerShell process you are using to create a remote session. I assumed that the default StartInfo environment variables were obtained from the process in which it is currently running. My limited testing seemed to indicate that this was so, but maybe not since your $env:SSH_AUTH_SOCK setting doesn't seem to be propagating. I'll need to take a closer look.
PaulHigin commentedon Jul 10, 2018
I found some time to look at this some more and I can verify that StartInfo does indeed contain the parent process environment variables, including SSH_AUTH_SOCK, and that they are being passed into the ssh process used for the connection and transport. So there must be something else that prevents ssh-agent from working.
I'll play around with ssh-agent to see if I can repro the problem.
rkeithhill commentedon Jul 11, 2018
I'm confused about something here. The
ssh-agentthat comes withGit for Windowswill create/use those env vars. But AFAICT, thessh-agentthat comes withOpenSSH(Windows 10 1803), it doesn't create or need those env vars.AmandaCameron commentedon Jul 11, 2018
Worth noting -- I'm running an Ubuntu-based laptop, not Windows where I'm encountering the issue.
The steps I listed above to dump the environment variables was showing only
PWDwith the latest change.PaulHigin commentedon Jul 11, 2018
I verified that the ssh process created by PowerShell remoting does not have the environment variables, by looking at the virtual file location /proc/[procid]/environ. It seems that our process creation code is not passing in the environment information correctly. I look deeper when I get some time.
PaulHigin commentedon Jul 12, 2018
My apologies. I was testing the old build without my fix and this is why I didn't see any environment variables. When I test a build with my fix I do now see the environment variables in the ssh process, including SSH_AUTH_SOCK. Next I'll see if I can get ssh-agent working.
AmandaCameron commentedon Jul 12, 2018
PaulHigin commentedon Jul 16, 2018
No problem. It looks like you did the same thing I did and tested on an older build. Glad to know it is working.
Added copy env vars from ProcessStartInfo to key/pair array used in c…