My personalized dotfiles and configs for Windows 10 ⚙️
Currently, I have the following SSH keys under version control:
MSI_id_rsa
/MSI_id_rsa.pub
- MSI Laptop’s Private/Public Key-PairLenovo_id_rsa
/Lenovo_id_rsa.pub
- Lenovo Laptop’s Private/Public Key-PairWSL_Ubuntu-CommPrev_id_rsa
/WSL_Ubuntu-CommPrev_id_rsa.pub
- WSL Ubuntu CommPrev Distro’s Private/Public Key-PairWSL_Ubuntu_id_rsa
/WSL_Ubuntu_id_rsa.pub
- WSL Ubuntu (20.04 LTS) Distro’s Private/Public Key-PairPlus the config
and known_hosts
files for each host mentioned above.
The following scripts are used to generate, migrate, manage, and symlink the SSH keys:
# Enable OpenSSH Client (need ADMIN Priveledges)
Add-WindowsCapability -Online -Name OpenSSH.Client*
# or via sudo
sudo Add-WindowsCapability -Online -Name OpenSSH.Client*
# Generate SSH keypair for MSI Laptop
ssh-keygen -t rsa -b 4096 -C "jimmy.briggs@jimbrig.com"
# save to file C:\Users\jimmy\.ssh\MSI_id_rsa
# No Password
# Copy public key to clipboard
Get-Content -Path $HOME\.ssh\MSI_id_rsa.pub | Set-Clipboard
# Add to GitHub
Start-Process "https://github.com/settings/ssh/new"
# Create config
New-Item -Path '$HOME/.ssh/config' -ItemType File
"Host *`r`n HostName github.com`r`n User git`r`n IdentityFile ~/.ssh/MSI_id_rsa`r`n IdentitiesOnly yes`r`n" >> $HOME\.ssh\config
cat ~/.ssh/config
# Test
ssh -T git@github.com
cd ~/Dev/sandbox
git clone git@github.com:jimbrig/jimbrig.git
# copy ~/.ssh files to .dotfiles/ssh/
Move-Item -Path $HOME/.ssh/* -Destination $HOME/.dotfiles/ssh/MSI -include ** -Force
# SymLink back to ~/.ssh
New-Item -Path "$HOME\.ssh\config" -ItemType SymbolicLink -Value "$HOME\.dotfiles\ssh\MSI\config"
New-Item -Path "$HOME\.ssh\known_hosts" -ItemType SymbolicLink -Value "$HOME\.dotfiles\ssh\MSI\known_hosts"
New-Item -Path "$HOME\.ssh\id_rsa" -ItemType SymbolicLink -Value "$HOME\.dotfiles\ssh\MSI\MSI_id_rsa"
New-Item -Path "$HOME\.ssh\id_rsa.pub" -ItemType SymbolicLink -Value "$HOME\.dotfiles\ssh\MSI\MSI_id_rsa.pub"
# generate key-pair
ssh-keygen -t rsa -b 4096 -C "jimmy.briggs@jimbrig.com"
# save to file /home/jimbrig/.ssh/WSL_Ubuntu-CommPrev_id_rsa
# no password
# create and edit config
echo "Host *\n HostName github.com\n User git\n IdentityFile ~/.ssh/WSL_Ubuntu-CommPrev_id_rsa\n IdentitiesOnly yes\n" > ~/.ssh/config
cat ~/.ssh/config
# or via VIM:
vim ~/.ssh/config
# copy to clipboard (NOTE: need alias for clip.exe here)
cat WSL_Ubuntu-CommPrev_id_rsa.pub | clip
# launch github ssh new page in browser:
cmd.exe /c start https://github.com/settings/ssh/new
# Test
ssh -T git@github.com
cd ~/dev
git clone git@github.com:jimbrig/wsl-dotfiles.git
In order to use ssh-keygen on Windows, you need to have the OpenSSH client enabled.
In order to enable the OpenSSH client, you essentially have two options :
To enable the OpenSSH client via Powershell, use the Add-WindowsCapability
option and specify the OpenSSH Client:
Add-WindowsCapability -Online -Name OpenSSH.Client*
Path :
Online : True
RestartNeeded : False
Note : you need to be administrator in order to enable OpenSSH on your computer.
You can also enable the OpenSSH client via the graphical interface :
Installing the OpenSSH client on Windows 10 will allow you to perform multiple commands via the Powershell : ssh-add, ssh-keygen (the one we are interested in), ssh-agent, ssh-keyscan and the ssh executable.
On Windows, for version greater than Windows 7, you can use ssh-keygen
in order to connect to your remote Git repositories.
Open Powershell and type the following commands:
ssh-keygen
The following prompts should look like this:
Enter file in which to save the key (C:\Users\schkn/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
SHA256:62DCkEWFILzHG8PhBEeQ2gzaEQ01/Y7VJEABWkuXGHI jimmy@DESKTOP-MSI
The key's randomart image is:
+---[RSA 3072]----+
|ooXOEO*+ |
|.+oX++o . . |
|o=B.+ . + |
|o.+X o . |
| + + +S |
| + . .. |
| o o . |
| o o |
| . |
+----[SHA256]-----+
In the first prompt, you can choose to save your public key in a separate file, but you will need to specify the entire path to the file.
If you chose to create your keys in a separate file, you will need to create a file named “config” into your .ssh directory
Note : the “config” file needs to have no extension at all, it cannot be named “config.txt” for example.
In order to configure your SSH keys, run the “New-Item” command to create a new file using Powershell.
New-Item -Path 'C:/Users/user/.ssh/config' -ItemType File
Note : you have to replace “user” by the actual user using the account
In the configuration file, paste the following content in order to select the correct key when performing Git commands.
Host *
Hostname github.com
User git
IdentityFile ~/.ssh/custom_id_rsa
Save your file, and you should be good to go.
# test/setup .ssh directory:
if (-not (test-path "$HOME\.ssh")) mkdir "$HOME\.ssh"
cd $HOME\.ssh
# generate key-pair associated with email address:
ssh-keygen -t rsa -b 4096 -C "jimmy.briggs@jimbrig.com"
# copy public key to clipboard
Get-Content -Path $HOME\.ssh\id_rsa.pub | Set-Clipboard
# navigate browser to GitHub settings to add SSH key from clipboard
Start-Process "https://github.com/settings/ssh/new"
# configure SSH
touch $HOME\.ssh\config
echo "Host *`n Hostname github.com`n User git`n IdentityFile ~/.ssh/id_rsa" >> $HOME\.ssh\config
if (-not (test-path "$HOME\.ssh")) mkdir "$HOME\.ssh"
cd $HOME\.ssh
ssh-keygen -t rsa -b 4096 -C "jimmy.briggs@jimbrig.com"
ssh-keygen -t rsa -b 4096
ssh-keygen -t rsa -b 4096
# copy public key to clipboard
Get-Content -Path $HOME\.ssh\id_rsa.pub | Set-Clipboard
# navigate browser to GitHub settings to add SSH key from clipboard
Start-Process "https://github.com/settings/ssh/new"
OpenSSHUtils
module to the server.
ssh-agent service
is disabled. Allow it to be manually started for the next step to work.ssh-agent service
to preserve the server keysssh-keygen
~/.ssh
directoryconfig
fileAdd-WindowsCapability -Online -Name OpenSSH.Client*
mkdir "~/.ssh"
cd "~/.ssh/"
ssh-keygen -t rsa -b 4096 -C "jimbrig2011@outlook.com"
New-Item -Path '~/.ssh/config' -ItemType File
$lb = "`r`n"
$txt = "Host *" + $lb + " Hostname github.com" + $lb + " User git" + $lb + " IdentityFile ~/.ssh/id_rsa" + $lb
$txt >> ~/.ssh/config
notepad "~/.ssh/config"
cat ~/.ssh/id_rsa.pub | Write-Output | clip
start "https://github.com/settings/ssh/new"