dahlbyk / posh-sshell

PowerShell helpers for SSH (previously part of posh-git.)
MIT License
143 stars 8 forks source link

Prompted for password on every console window open #20

Closed thardy closed 5 years ago

thardy commented 5 years ago

System Details

Issue Description

I am prompted for my ssh password every time I open a console tab in ConsoleZ. In my personal startup Powershell script, I have...

Import-Module posh-git
Import-Module posh-sshell
$Env:HOME = "$Env:USERPROFILE"
Set-Location 'C:\dev'
Start-SshAgent

I had to do that HOME reassignment because some unknown process was setting it to "U:". Getting posh-git to work on windows has been a real beat-down. It was about hour three before I even discovered posh-sshell. All my problems have been centered on getting ssh to work on windows. I remember when getting posh-git working was easy, but the past two times have been a nightmare.

At least I finally got Start-SshAgent working, but I was hoping to not have to enter my password every time I open a new console tab. If I'm doing something wrong, please help me diagnose.

JeremySkinner commented 5 years ago

This isn’t really anything to do with posh-shell.

The windows version of Openssh contains a windows service that remembers the password once it’s running, so you don’t need to enter the password again.

rkeithhill commented 5 years ago

If you use the built-in Windows ssh-agent service then you won't have to enter your password each time the shell starts. You enter the password once and it will be remembered across restarts. You do have to make sure the ssh-agent service is set to automatic restart and that the service is running.

rkeithhill commented 5 years ago

Just beat me to it. :-)

thardy commented 5 years ago

For ssh-agent service, do you mean "OpenSSH Authentication Agent"?

rkeithhill commented 5 years ago

Yes. Once that service is running, use the openssh version of ssh-add.exe to add your private key. It will prompt you for your passphrase and after that, you won't be prompted again. Watch out for the spring/fall Windows updates though. They always disable the service so I have to re-enable it after the update.

thardy commented 5 years ago

Worked like a charm. Thanks for your help. I was going off a set of instructions from a few years back.