Getting started with GitHub authentication using SSH on Windows

SSH on Windows

What happens when Apple adds something new to their product? Yes, you are right – they will tell about it many times and everywhere trying to impress people by telling them their new invented stuff is really new even if it is not. So, imagine, if they have just added SSH support to their Mac OS X, would they spread this news or not? I believe this question will be left unanswered as OS X (as any other unix like operating system already supports SSH out of the box). As it comes to Windows, many developers who work on Windows for some reason were waiting for this day to come for many years fighting with windows installing cygwin and git binaries and trying to make them love each other but it always was difficult to do it. And with 2018 Windows 10 update Microsoft actually added OpenSSH for the Windows 10!… And nobody knows about it even now. So if you have at least Windows 10 1903 release you are able to setup git integration easily. That is what we will do here.

Installing git

You have to download git binaries from here and install it. The process is very simple: agree with the agreement that you won’t read and press next, next, next…. until next button becomes the finish button. Pretty standard way though I recommend to change these settings as shown here

Ok, actually I lied here… SSH.exe is distributed with the git itself BUT we will not install it (last screenshot above).

Now, lets check if git is available. Go to desktop and create a folder named “git-repo-test”. No additional hacking skills needed here, just press RightMouseButton and Choose “Create a folder”.

Succeed with this? AWESOME! Now open this folder with doubleclick, press Ctrl+L in the opened explorer window and you will be able to copy the path to the folder. Copy it. Then, go to searchbar at the left bottom and type “cmd” and open it.

In the opened console type “cd ” (space at the end) press rightmouse button to insert the copied text ( or shift+insert). and press enter. 

Now type “git init”.

So, the repo is created!

Add your first file and commit it (note, first lines are needed to set your mail and name. Replace these values with your owns. These values will be displayed in github commits log)


git config user.email "[email protected]"
git config  user.name "John Doe"

echo "h1. This is the readme file." > README.md

git add README.md

git commit -m"Added a readme file".

And add a license file. For that, go to https://choosealicense.com/ and select a license for your project. I will choose https://choosealicense.com/licenses/mit/ to allow all the other developers to use my project anyway as they want. What it you don’t select a license? Well, this means that other developers will not be allowed to use your project in any way, it will not be legal. So, create a new file (with a mouse and a notepad) and copy the license text, replace year in it and save.

Check the repo status


git status

Add this file to be included in commit and commit it


git add License.txt

git commit

Note, this time we don’t use -m flag for git commit. This will open a window with notepad allowing you to enter some message for commit.

All the text after sharp sign are not included in the message, just ignore it. Write your message at the first line and close the notepad. The commit will be done.

So, we’ve added few files and commited them to LOCAL repo. 

Easy? Let’s continue to the more complex part (hollywood movie like hacking skills will be required here).

OpenSSH stuff

Now, let’s create an SSH key. In the same console window type “ssh-keygen -t rsa -b 4096” and press enter. When it will request a password – just press enter to make it empty. Ok, the ssh key is created.

This will create 2 files: public  key(id_rsa.pub) – share it with anyone you wont, make a tatoo with this text or write it on your carpet under the door – doesn’t matter. Absolutely safe to share it.

But the private key (id_rsa) – never share this with anyone! It is like a keys for your home or car. Keep it in secret!

View the public key by typing “notepad %userprofile%\.ssh\id_rsa.pub” . Copy this value.

Now, go to the github ssh key add page and paste you public key into the textarea, then press green button to submit.

Ok, the SSH key is added. Lets create a repo and push your changes!

Create a new repo here https://github.com/new

You will see some tutorial here, scroll down to the second paragraph and copy the first line (git remote add…)

Paste it in the console.  And push all the changes to the remote.


git remote add ... - your line here

git fetch origin

git push --all

Note, further, in order to push something, you can use “git push origin main” (where main – is your branch name).

So, if you succeeded, go back to github and you will see your files on the github site.

Hope this tutorial will be useful.

Loading

This entry was posted in Computers, BY and tagged , , , , , , , , . Bookmark the permalink. | Short link:  http://p1rat.ru/lezzz/oO69q

Leave a Reply