# Using GIT & SSH in Windows 10/11 ## Enabling SSH on Windows (From Stack overflow) OpenSSH is available as part of Windows 10 which makes using SSH from cmd/powershell much easier. It also doesn't rely on having git installed. Open Manage optional features from the start menu and make sure you have Open SSH Client in the list. If not, you should be able to add it. Open Services from the start Menu Scroll down to OpenSSH Authentication Agent > right click > properties Change the Startup type from Disabled to any of the other 3 options. I have mine set to Automatic (Delayed Start) Open cmd and type where ssh to confirm that the top listed path is in System32. Mine is installed at C:\Windows\System32\OpenSSH\ssh.exe. If it's not in the list you may need to close and reopen cmd. Once you've followed these steps, ssh-agent, ssh-add and all other ssh commands should now work from cmd. To start the agent you can simply type ssh-agent. You can also start the agent from the Services application ## Generating an SSH Key General usage: (from cmd or powershell) ssh-keygen -t #keytype# -f #filename# You generally want everything in your #homedir#\.ssh directory - if it doesn't exist run mkdir .ssh from your homedir (the default dir for powershell & cmd in non admin mode) So from your homedir run cd .ssh then run say ssh-keygen -t ed25519 It will ask for you to create a passphrase for this key & to confirm it for the above type of key the following files will have been created: -a---- 31/07/2023 21:01 464 id_ed25519 -a---- 31/07/2023 21:01 99 id_ed25519.pub The .pub is the public key you upload to the Gogs/Github/Gitlab site, the other file is the secret part of the key you keep to yourself ## Adding the created key to your keyring from your home dir run: ssh-add it will ask for your passphrase you can check what is in the agent/keyring by running ssh-add -l or ssh-add -L Any keys you add should still be there after a reboot Github Desktop & VSCode will automatically use your keys once in the agent, Github Desktop will ask for the passphrase for a key once & cache it, while VSCode will ask for the passphrase each time. ## Getting git to use Windows OpenSSH Git uses the environment variable GIT_SSH You can find the path to ssh with: C:\> where ssh C:\Windows\System32\OpenSSH\ssh.exe This is the windows ssh, which is the one that can use the windows ssh agent service You set the GIT_SSH environment variable with C:\> set GIT_SSH=C:\Windows\System32\OpenSSH\ssh.exe And check it with C:\> set GIT_SSH GIT_SSH=C:\Windows\System32\OpenSSH\ssh.exe Now git will be able to use the keys that you generated earlier. This fix is so far only for the current window. To fix it completely you need to change your environment variable. (WIN10 - should be similar to WIN11) Select the Menu, search for Environment -> select Edit the system environment variables Select Environment Variables... In the User variables section create a new GIT_SSH variable and set to the desired path as above press OK to set the variable value. Press OK to close all windows Now any future command windows you open will have the correct settings.