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
Changes to the prompt are reverted when running start-ssh-agent.cmd #640
Comments
Rather than use Git's From a PowerShell window run Now let's start the ssh-agent service and configure it to automatically start upon reboot. Open PowerShell as administrator and execute:
Cd to your That's it! Now ssh-agent is running and serving your passphrase. It will continue to do so after a reboot (without having to re-enter your passphrase). And even better, ssh-agent will work for apps (like Visual Studio) that you start from the Start menu instead of the PowerShell console - which you would have to do it you used start-ssh-agent.cmd. |
@rkeithhill thanks for the useful info! Can I start the agent only when I need to? Will this work? Get-Service ssh-agent | Start-Service I don't want it to start on every boot, I rarely use Git on Windows. |
Yes but you need to do that from PowerShell running elevated. And you can simplify that to |
@rkeithhill on Linux though, it works that you need to add your private key to the agent whenever you're going to use it. Your key only gets cached into the agent, you're not adding anything permanently. |
Yes, it is different in Windows. Windows stores your passphrase (encrypted) using DPAPI (data protection API) - I think. So it is remembered across reboots without you having to re-enter it. That store is local to your machine and is only accessible via your user account on that machine. |
The Start-Service thing doesn't work. What am I doing wrong?
It's an elevated Powershell session, and ssh should be available: C:\Windows\system32> Get-Command ssh | Format-List
Name : ssh.exe
CommandType : Application
Definition : C:\Windows\System32\OpenSSH\ssh.exe
Extension : .exe
Path : C:\Windows\System32\OpenSSH\ssh.exe
FileVersionInfo : File: C:\Windows\System32\OpenSSH\ssh.exe
InternalName:
OriginalFilename:
FileVersion: 7.6.0.0
FileDescription:
Product: OpenSSH for Windows
ProductVersion: OpenSSH_7.6p1 for Windows
Debug: False
Patched: False
PreRelease: False
PrivateBuild: False
SpecialBuild: False
Language: English (United States) |
Make sure you run PowerShell as Adminstrator. On Linux, you'd have to use |
I solved it! I typed "Services" in the Start Menu and I got a window listing all the services currently installed on the machine. I noticed that, next to "OpenSSH Authentication Agent", it said "Stopped". I ran |
Ah yeah, by default that service is disabled. So you can't start it until you changed the startup type away from disabled. So manual works as does automatic (and anything else other than disabled). |
Closing this issue. If you think it shouldn't be, you can re-open it. |
System Details
Issue Description
Hi, I'm experiencing an issue with posh-git. I'm coming from Linux and this is the first time I try to use Git on Windows (specifically in a Powershell session) so I'm not familiar with how Powershell works, how to configure it and whatnot.
I installed posh-git and managed to make it permanent so that it gets loaded automatically whenever I open a Powershell session. I tried it for a while, making a few commits and it works fantastically, much faster and more responsive than MinTTY. The problems came when I had to push my commits.
I authenticate myself on my remote repository using an SSH key. I saw that Git on Windows comes with a handy Batch script that runs an ssh-agent in the background. Whenever I run it however, the git prompt is gone! The Powershell prompt seems like it's reverted to its default settings. I'll show some screenshots.
This is as soon as I start my Powershell (I've not hit Enter yet):
and then as I hit Enter:
Interestingly enough though, if I type
exit
I'll get the Git prompt back (screenshot below), so it looks likestart-ssh-agent.cmd
runs in a sub-shell, which doesn't get the Git prompt.The text was updated successfully, but these errors were encountered: