Thursday, 11 April 2019

Note to self: Accessing GitHub via SSH

So, as a tech note to myself, this is how I set up access to GitHub.com via SSH both on Windows 10 and on Ubuntu Linux 18.10. In order to keep this short and to the point, let's assume that both SSH and Git has already been setup.

Windows 10

I'm using Git for Windows 2.21.0.

The Git installation comes with bundled OpenSSH, so I do not need the GIT_SSH environmental variable. If GIT_SSH exists, Git will use explicitly the specified application whenever it attempts to use SSH instead of the OpenSSH. 

This little detail really tripped me over for a while as because of some past setup I had GIT_SSH pointing to plink.exe while I had been eagerly configuring OpenSSH. How odd it was that Git kept failing with SSH (plink.exe) while direct SSH (OpenSSH) connections worked just fine...

Step 1: Generate a RSA key pair

$ ssh-keygen -t rsa -b 4096
In the dialogue that follows, I chose to store the new key as
/c/Users/<user>/.ssh/github_id_rsa
Mind you that the above notation is as it is used in the Git Bash. Two new files were created:
C:\Users\<user>\.ssh\github_id_rsa (private key)
C:\Users\
<user>\.ssh\github_id_rsa.pub (public key)

 Step 2: Edit ssh config file

I added following entry to the C:\Users\<user>\.ssh\config (and if the file does not exist, just create a new one):
Host github.com
    Hostname github.com
    User git
    IdentityFile C:\Users\
<user>\.ssh\github_id_rsa

Step 3: Store public key to GitHub account

I opened the C:\Users\<user>\.ssh\github_id_rsa.pub file, which contains a long string, which begins with "ssh-rsa ...", and then copied the text to clipboard.

In GitHub,
  1. I opened my profile Settings / SSH and GPG keys
  2. Clicked New SSH key
  3. Named the key in Title
  4. Pasted the public key's text into Key
  5. Clicked Add SSH key
The page lists all added SSH keys. The new one shows at this point as Never used - Read/write.

Step 4: Test SSH connection to GitHub

In Git Bash I tried if the basic SSH authentication works. Note that one must always use the user git instead of own GitHub user account.
$ ssh -T git@github.com
If all goes well, the server responds:
"Hi <github user>! You've successfully authenticated, but GitHub does not provide shell access."
If the attempt fails, try ssh -Tv git@github.com and figure it out. I did, eventually.

Step 5: Add the private key to ssh-agent

If the ssh-agent is not already running, start it with following command:
$ eval $(ssh-agent -s)
If the agent is running it's pid is shown. Next add the private key to the ssh-agent (again, in Git Bash).
$ ssh-add /c/Users/<user>/.ssh/github_id_rsa
If successful, following message is shown.
Identity added: /c/users/<user>/.ssh/github_id_rsa (<user>@<host>)

Step 6: Clone a repository

One of my public repositories is mstenback/reference_java, which contains small reference applications. (While they are mostly small and simple, they provide a good reference point as I implement the same applications also in other langauges and scripts, such as Python, Bash, Golang and so on. It's works for me as way to learn new languages.)
$ git clone git@github.com:mstenback/reference_java
Note that the repository must be cloned by using the SSH notation instead of HTTPS.

Step 7: Commit and push changes

After making a small change to README.md I committed the change
$ git commit README.md
and then pushed the changes to GitHub
$ git push
At this point, after a long evening trying to figure this out, I allowed myself feel a bit pleased when the connection finally worked as intended.

Finally, as a minor detail, if I would check my SSH key status in GitHub profile, it would now show
Last used within the last week - Read/write

Ubuntu Linux 18.10

Essentially all the steps are the same, with couple of exceptions.

1) SSH key files are located in /home/<user>/.ssh/

2)  Using OpenSSH 7.7p1 (not that it makes any practical difference in this case).

Monday, 10 April 2017

An Arduous Journey: After father's death

It has been a while since I last contributed to this blog.

I turned forty in the February but there was nothing to celebrate; my father died of cancer two days prior my birthday. He began complaining about pains and lost his appetite for food in January and about a month later he died of liver cancer.

I did not have a chance to settle things with my father and it makes me feel... empty. Not particularly sad nor anxious (well,a bit certainly), but mostly I've been just emotionally deflated. When my father realised that he was going to die, in combination with his constant pains and malnourishment, he just closed himself from people around him. No final words to anyone in any form that I know of, but there was this one thing: I found the last video he recorded on his camera. It was just about five minutes of his wife working in the kitchen, preserving some vegetables in jars for later use. There was no talking or interaction, but as I watched that video I did get a strong feeling that my father had found some level of comfort, if also sadness, in that moment. Then he turned off the camera, and that was the last of it all.

Up until now I've had nothing to say or write. There have certainly been thoughts and emotions within me, but nothing that I felt like sharing with others. My relationship with my father was a bit complex and strained, but I had always hoped that we would still have an opportunity to find a way to reconnect as a father and son, but to be honest I do not know for certain if that was something my father also wanted. I'd like to think it was, but we did not talk after he got his diagnosis. I tried to call him several times, but he was not inclined to talk on the phone. I decided to go and see him in person (it's a 4-5 hours trip by car), but two days before I was supposed to travel he was hospitalised. I decided to travel and see him on the very next day, but in the morning as I was about to head out I got the word that he had died two hours after midnight.

He did leave a large collection of photos and videos that I'm going to take over along with his writings on his computers. Perhaps through that legacy I may still learn something about the man who was my father.

From my Arduous Journey's point of view the effects have been mostly subtle, I think. It has been more difficult to center and focus, and to find inner peace, but I  have not been feeling all that anxious or even depressed. Just... somewhat disconnected.

However, I have gained some weight, and that is a dead giveaway that not all is well; my weight is usually the best indicator that I'm getting a little out of balance but once I notice this I can usually begin to identify and address my issues. It's spring time and I'm about to have some vacation time so that certainly helps. Another obvious sign has been that I've spent too much time on my sofa watching YouTube videos (and/or sleeping), but now that I finally got around writing about this all I feel that I'm about to turn things around for the better.

Wednesday, 11 January 2017

Politics: You, the people, expect more from your representatives

As Finland's Municipal Elections are just few months away I find myself  being involved with it..

In the spirit of Stoic philosophy I do not concern myself with my paltry chances of actually becoming elected; in the end I have very little control over the matter. However, as an official candidate for a political party I am granted a voice and an opportunity to use it to appeal to the people: expect more from those who would become your representatives!

Demand your representatives to rise above partisan politics and to work for the common good of the whole society and not just for their personal gratification, party politics and various interest groups.

Demand your representatives to stand for the matters that unite us as a society instead of taking the low road by riding on issues of bigotry and hate, fear and suspicion, greed and envy, and all those other matters that would divide us and drive us all apart.

You, the people, must demand that those who ask for the power to influence your lives prove themselves to be worthy of your trust and respect. Demand that the people of influence and power within the society are to be held against higher standard!

Never let them forget that a government, be it local or national, serves at the pleasure of the people. Be not afraid to rise up and challenge all those who would argue that transparency, personal integrity, professionalism and careful consideration of all matters before decision should not be expected at all times in politics.

Challenge your canditates! Let them know that you expect them to be and to know better.  The people have a voice and when it is focused it is powerful and it will be heard.