How to SSH into Linux System with Private Key


By default, Linux allow users to SSH into the system using only password without providing any private key. This is actually an insecure method of authentication as any users can SSH into the system as long as they have the username and password. Therefore we add an additional layer of security for the SSH authentication using owner’s private key.

First we need to generate an SSH-Key. The key format required for Windows and Linux are different, .ppk format are required by Windows while Linux can accept any kind of format as long as the key are in OpenSSH format.

For Windows User

First we have to generate a key pair that contain a public key and a private key using PuttyGen (Download PuttyGen here). After downloading the program, launch it. Follow the following steps to generate a key pair:

  1. For type of key to generate, choose RSA from the list.
  2. Click on Generate button under Actions to start the generation.
  3. Move your mouse pointer around in the blank area of the Key section, below the progress bar (to generate some randomness) until the progress bar is full;
  4. A private/ public key pair has now been generated;
  5. In the Key comment field, enter any comment you’d like, to help you identify this key pair, later (e.g. your e-mail address; home; office; etc.) — the key comment is particularly useful in the event you end up creating more than one key pair;
  6. Optional: Type a passphrase in the Key passphrase field & re-type the same passphrase in the Confirm passphrase field (if you would like to use your keys for automated processes, however, you should not create a passphrase);
  7. Click the Save public key button & choose whatever filename you’d like (some users create a folder in their computer named my_keys);
  8. Click the Save private key button & choose whatever filename you’d like (you can save it in the same location as the public key, but it should be a location that only you can access and that you will NOT lose! If you lose your keys and have disabled username/password logins, you will no longer be able log in!);
  9. Right-click in the text field labeled Public key for pasting into OpenSSH authorized_keys file and choose Select All;
  10. Right-click again in the same text field and choose Copy.
  11. SSH into target machine to upload the public key.
  12. Go to ~/.ssh/authorized_keys and copy over the content.
  13. Now you should be able to SSH into the target server by providing .ppk format private key.

NOTE: PuTTY and OpenSSH use different formats for public SSH keys. If the SSH Key you copied starts with “—- BEGIN SSH2 PUBLIC KEY …”, it is in the wrong format. Be sure to follow the instructions carefully. Your key should start with “ssh-rsa AAAA ….”

For Linux User

Linux user require no special program to generate SSH key pair. Follow the following steps below to generate a key pair:

  1. Type the following command into the terminal.
    ssh-keygen -t rsa -b 2048 -v
  2. You should see the following message after you enter the above command:
    Generating public/private rsa key pair.
    Enter file in which to save the key (~/.ssh/id_rsa): easierit
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in easierit.
    Your public key has been saved in
    The key fingerprint is:
    bb:c6:9c:ee:6b:c0:67:58:b2:bb:4b:44:72:d3:cc:a5 localhost@localhost
    The key's randomart image is:
  3. You should now have two key files under ~/.ssh.
  4. Next, we need to upload the public key to the server we will be SSH into using the following command.
    ssh-copy-id -i ~/.ssh/ root@
  5. Now try logging into the machine, with ssh root@, and check in: ~/.ssh/authorized_keys to make sure we haven’t added extra keys that you weren’t expecting, you may still want to use a password. Your authorized_keys file should look something like this.
    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAX ...
  6. Now you can try to login with your private key from original Linux terminal using the following the command.
    sudo ssh -i ~/easierit.pem root@

Enable Services on Startup in Linux

The chkconfig command can also be used to activate and deactivate services. The chkconfig --list command displays a list of system services and whether they are started (on) or stopped (off) in run levels 0-6.

abrt-ccpp          0:off  1:off  2:off  3:on   4:off  5:on   6:off
abrtd              0:off  1:off  2:off  3:on   4:off  5:on   6:off
acpid              0:off  1:off  2:on   3:on   4:on   5:on   6:off
atd                0:off  1:off  2:off  3:on   4:on   5:on   6:off
auditd             0:off  1:off  2:on   3:on   4:on   5:on   6:off
autofs             0:off  1:off  2:off  3:on   4:on   5:on   6:off
blk-availability   0:off  1:on   2:on   3:on   4:on   5:on   6:off
certmonger         0:off  1:off  2:off  3:on   4:on   5:on   6:off
cgconfig           0:off  1:off  2:off  3:off  4:off  5:off  6:off
cgred              0:off  1:off  2:off  3:off  4:off  5:off  6:off
cpuspeed           0:off  1:on   2:on   3:on   4:on   5:on   6:off

For example, if you wish to enable apache2 service in your system during startup, you can use the following command to activate it:

chkconfig httpd on

Similarly to turn off the service, use:

chkconfig httpd off

How to Install Windows 10 Cumulative Patch KB3189866

How to Install Windows 10 Cumulative Patch KB3189866
I’m seeing posts all over the web from folks trying to install the latest Windows 10 Anniversary Update (version 1607) cumulative update. KB3189866 is supposed to bring Win10 AU to build 14393.187, but reports say the installer gets stuck at 45 percent, 48 percent, 95 percent, and various other points along the way.The problem’s widespread, and Microsoft has known about it since shortly after the patch dropped. Since it’s a cumulative update, there’s no easy solution.

Microsoft will certainly figure out what’s blocking the patch, but in order to fix it the company will have to release a new cumulative update. Unless it can find a magic way to modify a released cumulative update, the only solution is a new cumulative update that absolves the sins of the original. That’s one of the big problems with these massive, one-way “as a service” patches. It’s also a totally predictable problem.
If you’re faced with this issue, be of good cheer: There’s an easy solution. Some suggest that you crank up Internet Explorer and download the patch from the Microsoft Update Catalog. There are links for the 32- and 64-bit versions of Win10, but they require Internet Explorer and the installation of an ActiveX control.
Fortunately, there’s a trick for getting to the Microsoft Update Catalog without using IE and without installing a 1990s-era ActiveX program. Make sure you’re running Windows 10 Anniversary Update, version 1607 (type winver in the Cortana Search box). You can then use any browser to click on this link.

If you have an RSS recognition add-on in Firefox or Chrome — for example “RSS Subscription extension (by Google)” for Chrome — you will immediately see links for downloading KB 3189866. They are:

  • Cumulative Update for Windows 10 Version 1607 for x64-based Systems (KB3189866) — this is the 64-bit version of the patch
  • Cumulative Update for Windows Server 2016 for x64-based Systems (KB3189866) — the version for Server 2016
  • Cumulative Update for Windows 10 Version 1607 (KB3189866) — which is the 32-bit version

If you don’t have an RSS recognition add-on, you see raw RSS text, which is pretty easy to decipher. Look for those three entries.

Click on the link to go into the Microsoft Update Catalog, click Download Now, click on the MSU file you want to download, choose to use the Standalone Update Installer, and click OK.

KB3189866 will install itself; you reboot and carry on.

Helper Service in Laravel 5.2

Helper Service in Laravel 5.2

First, create a new PHP file in app\Helpers directory, for example UserServiceProvider.php.


use Illuminate\Support\Facades\Session;

function is_logged_in()
    if (Session::get("user_id") != "") {
        return true;
    return false;

Next, create new providers using php artisan make:provider HelperServiceProvider in the console. Then update the file content as followed:

namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class HelperServiceProvider extends ServiceProvider
     * Bootstrap the application services.
     * @return void
    public function boot()
     * Register the application services.
     * @return void
    public function register()
        require base_path() . '/app/Helpers/UserServiceProvider.php';

Lastly, add the reference to the helper provider in config\app.php, as followed:

'providers'=> [


Now, you can call the helper function anywhere by just calling the method is_logged_in().

MySQL Clone Database

MySQL Clone Database

To clone a database named database_one into ‘database_two’ in MySQL, the following command can be used:

$root@server: mysqldump database_one -u username -p > database_one.sql
$root@server: mysql database_two -u username -p < database_one.sql

where username is the username of your MySQL database.

Currency Exchange Rate in PHP

We might sometime need to deal with multiple type of currencies when developing e-commerce website. Multiple type of currencies mean we have to take care and get updated currency exchange rate to correctly fix the price of any product. In PHP, we can easily make use of Yahoo Finance to generate currency exchange rate.


// $from => Currency to convert from
// $to   => Currency to convert to
function get_exchange_rate ($from, $to){
    $currency = [ "from" => $from, "to" => $to ];
    $ticker = $currency["from"] . $currency["to"] . "=X";

    // Retrieve data from Yahoo Finance
    $open = fopen("$ticker&f=sl1d1t1c1ohgv&e=.csv", "r");
    $exchange_rate = fread($open, 2000);
    $exchange_rate = str_replace("\"", "", $exchange_rate);
    $exchange_rate = explode(",", $exchange_rate);

    // return exchange rate
    return $exchange_rate;

$rate_USD_SGD = get_exchange_rate("USD", "SGD");