For the sake of continuous learning — and so I could use a couple work-related applications that don’t work even with WINE — I decided to spend more time in Windows. Let’s see if I can comfortably use Git from PowerShell. I’ll use the OpenSSH for Windows server for key management, since it’s already available on my system.
Setting up Git
Winget knows about several Git-related packages, so my installation command needs to be specific.
The installation puts Git’s
cmd folder onto
$env:Path, but PowerShellwon’t see that until I refresh the variable.
And there it is!
I need to start a new session eventually, though. Can’t go around refreshing my path like that every time I open a new terminal. Though I suppose I could put this in PowerShell initialization.
I know Git Bash is a thing, but I’m trying to learn Windows — not just paste a comforting layer of UNIX duct tape over everything. Said while writing a blog post from Vim on WSL.
Anyways, it looks like
ssh-keygen is accessible via PowerShell.
I add an SSH key with the details from
C:/Users/brian/.ssh/id_rsa.pub, and check out a repo.
That was easy enough. There are a couple bits missing from my regular Git day, though.
Conveniences with posh-git
For starters, I enjoy a pretty shell prompt with version control details. Let’s install the beta release of posh-git.
Lovely! I can customize it later.
Getting an SSH agent with posh-sshell
I dislike entering my ssh passphrase every time I interact with a version control server. Need to get some sort of
Looks like posh-sshell can help with that?
Of course, I should probably enable the
ssh-agent service from an Admin PowerShell session:
I don’t know why “Manual.” That’s what this Stackoverflow answer said, and it seems to be working.
Over in my PowerShell init, I make sure the new modules are loaded, set some handy aliases for using my SSH keys, and start the SSH Agent.
After starting a new session, everything seems successful.
Did you see this bit?
That warning is a known issue with OpenSSH on Windows, and should go away in the next month or two. The bad news: until it’s fixed, different repository servers handle the mismatch differently. What I noticed while working through the process that became this post:
- Github issued the warning but let me continue
- A server running Gitea issued the warning and would not let me continue
This is significant enough to highlight:
If you’re using the Windows OpenSSH server before the 2020 Fall Update, you may want to skip the
But other than that, things are working pretty good. Learning is fun!
Got a comment? A question? More of a comment than a question?
Talk to me about this page on: mastodon
Added to vault 2024-01-15. Updated on 2024-02-07