New Stuff

I am using Visual Studio 2012 Preview 3.1 on Windows 11. I didn’t plan on it but I just installed them when I saw them available on my personal laptop. I wouldn’t do it to my work laptop but I don’t mind being bleeding edge on my personal machine.

I like new stuff. It’s been my nature for decades in my software engineer career. I believe it has been doing good to me. Being a software engineer, you always need to keep up with new technology. The technology I used to work with a decade or 2 ago is completely different from what I deal with today.

If you find it hard to do, software engineer might not be the career for you. If you find it fun to do, then you have a good chance to be a good software engineer.

I’m not saying new stuff is always better. I think balance is very important. Using everything new is not good and sticking with old way only is not good either. It’s a matter of balance.

This blog is a place where I explore new stuff and keep it so that I can come back to it if I forget and share it with the people all over the world.

WordPress Migration to OCI: Opening Ports

When you provision an instance (host) on OCI, a public IP address is assigned.

I have already covered how to open ports on OCI in my previous post.

https://hayato-iriumi.net/2020/02/02/open-http-traffic-on-oracle-cloud-infrastructure/

Next time, I will cover how to install the necessary software on the newly provisioned instance.

SSH Public and Private Keys

As we use services like GitHub, GitLab, BitBucket, Azure DevOps and etc, we are required to use SSH public/private key for authentication. SSH public and private keys can easily be created using ssh-keygen tool on your computer. You may need to install Git (Git Bash) if you use Windows as your client machine.

So ssh-keygen lets you generate private/public key pair on your machine. Here is how it looks like.

[amaterasu48@hogesvr ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/amaterasu48/.ssh/id_rsa): 
Created directory '/home/amaterasu48/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/amaterasu48/.ssh/id_rsa.
Your public key has been saved in /home/amaterasu48/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:4Yuih+5+BowypaHOk/bp9mGXho24Kbyf/SaNZCF1upY amaterasu48@hogesvr
The key's randomart image is:
+---[RSA 2048]----+
|                 |
|     . .         |
|    . o .        |
|. .. o . .       |
|.*  . + S        |
|* o .E+...       |
|=..+==+=.        |
| O.o@++o         |
|.=&%.o+.         |
+----[SHA256]-----+

When you execute ssh-keygen, it asks you to enter passphrase. You can enter it or choose not to enter it. It generates 2 files at ~/.ssh They are id_rsa.pub and id_rsa.

id_rsa.pub is the public key. The content of the file looks like the following.

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDsI1olqIE+PRQ0I5PhtyAHqWf0Z9ImXq3RbIclMi123um
5yi+/RyNULJsXURXj9I5F827YROxgbQCZurXciiBCz9q9Gfktf4gyjsPcm1zAavw30lSl48mNJ1
GkkbIP2kMYPbEZqhnLlTngzWq7ApAA6bkbqftVvpysoRMq7j43oAGHd+tLPZYgkwxK2jkA8IvEH
BM++tajmqWpOGJ2IKIU+38TfKBmtcUSVwTBtiJj3IVusdTrJtAi19puSA6Q/KonzERlDxwj6ddc
cnDhnuuaLNiOdrEYXBq1fS1oWd93usb2HvZm9AFHN8Nf9q0NUq/ZHKsDl0vOucl76rqP8Cpn 
amaterasu48@hogesvr

You usually paste the string to services like GitHub for authentication.

id_rsa is the private key which you never want to expose to anyone at all. The public key that you uploaded to a service like GitHub is used to encrypt data on the other end and your private key is used to decrypt the data. The private key that was generated in this example looks like the following. Don’t worry, I’ve already got rid of the sample private key from a machine where I generated the sample keys.

-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA7CNaJaiBPj0UNCOT4bcgB6ln9GfSJl6t0WyHJTItdt7pucov
v0cjVCybF1EV4/SORfNu2ETsYG0Ambq13IogQs/avRn5LX+IMo7D3JtcwGr8N9JU
pePJjSdRpJGyD9pDGD2xGaoZy5U54M1quwKQAOm5G6n7Vb6crKETKu4+N6ABh3fr
Sz2WIJMMSto5APCLxBwTPvrWo5qlqThidiCiFPt/E3ygZrXFElcEwbYiY9yFbrHU
6ybQItfabkgOkPyqJ8xEZQ8cI+nXXHJw4Z7rmizYjnaxGFwatX0taFnfd7rG9h72
ZvQBRzfDX/atDVKv2RyrA5dLzrnJe+q6j/AqZwIDAQABAoIBAGvoC73Brq2+Q4k/
6MfwYtaddz+cYc/e3BcjPO6ma1gyrSOVXRRPcbl5WLXi+9nbW1hj0Xd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rbWy6DJNXhwqQpyt0NPt4yLt
nxu9sz7ja+NJ1yuq26yHonoFL6B5vKsBTLO+Tb2DIB74IBUdFeqXHg==
-----END RSA PRIVATE KEY-----

Once you generated your private/public key pair, go to your icon –> Setting –> SSH and GPG Keys in GitHub to add the public key to it and then you will be able to do git clone and other operations against GitHub.

I wanted to cover this basic so that I can move on to Jenkins installation and configuration on Azure.

PowerShell Doesn’t Fail Jenkins Job

When dealing with automation on Windows platform, PowerShell comes in very handy and there is no doubt about it. Things can be automated quite easily with it.

However, you want the Jenkins job in which PowerShell is used to fail if your PowerShell script fails. I have had cases where I saw my script crapped out but the job itself succeeded.

To solve the problem, all you have to do is to add the following line at the beginning of the PowerShell script step.

$ErrorActionPreference = "Stop"

This will “successfully fail” your Jenkins job if your script throws any exception.

Free SSL

I tried to do a research on how to create your own Certificate Authority (CA) and issue SSL certificate for your own server, but I ended up with coming across this free service.

https://www.sslforfree.com/

I successfully implemented SSL on my own instance of Jenkins on Azure. After generating the certificate along with private key, I uploaded the files to Azure and made my change in nginx configuration file. Remember that NGINX is playing a reverse proxy role.

server {
    listen 80;
    server_name yourstuff.whicheverregion.cloudapp.azure.com;
    return 301 https://yourstuff.whicheverregion.cloudapp.azure.com;
}
server {
    listen 443 ssl;
    server_name yourstuff.whicheverregion.cloudapp.azure.com;
    ssl_certificate /etc/nginx/ssl/certificate.crt;
    ssl_certificate_key /etc/nginx/ssl/private.key;
    location / {
        proxy_set_header        Host $host:$server_port;
        proxy_set_header        X-Real-IP $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header        X-Forwarded-Proto $scheme;
        proxy_pass          http://localhost:8080;
        proxy_redirect      http://localhost:8080 http://yourstuff.whicheverregion.cloudapp.azure.com;
        proxy_read_timeout  90;
    }
}

Nowadays, there is almost no website that doesn’t use SSL. I guess I should start to use SSL for Free to make this website more secure.

Linux Mint is just for Beginners?

When I said, “I use Linux Mint as my main desktop at home.”, I was apparently and jokingly ridiculed by my colleague because “it’s for beginners.”

I used to like to use computers for the sake of using computers and I still do to a degree, but I don’t believe that using Linux Mint makes you a novice Linux user. There are so many configurations I don’t even have to deal with so that I can spend my time for better things like working on more useful software.

Let’s not categorize people who use certain distro as novice or advanced users. What’s important is what you do with the OSes.