Ubuntu Generate SSH Key
Ubuntu generate SSH key stands for a process required to setup the right security environment for several big data frameworks like Apache Hadoop or Apache Spark. This setup is required to perform selected operations on a computing cluster including starting and stopping of those big data frameworks and other distributed daemon shell operations. The steps to generate such keys is the same and is performed within the Ubuntu Linux operating system as an example below.
The goal is to authenticate different users of a particular big data framework. It is therefore required to provide a public and private key pair for this specific big data framework user in order to share it with different users. In Ubuntu generate SSH key is done via the key-gen command that can be used and we just take the defaults meaning no location changes (just press enter) and no passphrases (just press enter twice again):
$ ssh-keygen -t rsa
Output:
Generating public/private rsa key pair. Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/ubuntu/.ssh/id_rsa. Your public key has been saved in /home/ubuntu/.ssh/id_rsa.pub. The key fingerprint is: SHA256:52QTxDTyYbAxx+wjR16dY8oBBH2TmCGdVtit5JCGzhU ubuntu@i-3992cc97 The key's randomart image is: +---[RSA 2048]----+ | B%E%.+ . | | .@^oO * | | o.BoB * . | | + =.= | | So=. | | = . | | . | | | | | +----[SHA256]-----+
It generates a public and private key pair in the .ssh directory of the particular Ubuntu user as shown below. The parameter ‘-t rsa’ indicates one specific public-key cryptosystem called RSA that is no direct abbreviation. Instead the letters RSA stand for the surnames of R. Rivest, A. Shamir, and L. Adleman that created the algorithm in 1977. Lets have a look into the directory in order to understand what files have been generated using the following commands:
$ cd .ssh
$ ls -al
Output:
total 20 drwx------ 2 ubuntu ubuntu 4096 Apr 1 07:18 . drwxr-xr-x 4 ubuntu ubuntu 4096 Apr 1 07:14 .. -rw------- 1 ubuntu ubuntu 213 Apr 1 06:03 authorized_keys -rw------- 1 ubuntu ubuntu 1675 Apr 1 07:18 id_rsa -rw-r--r-- 1 ubuntu ubuntu 399 Apr 1 07:18 id_rsa.pub
We observe the generated SSH key pairs with the public key being in the file id_rsa.pub and the private key in the file id_rsa while the latter file is sometimes also called your identification file. This public key content from id_rsa.pub is copied to the authorized_keys file with the command below. In addition we need to set the read and write permissions for the authorized_keys file as follows:
$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
$ chmod 0600 ~/.ssh/authorized_keys
$ cat ~/.ssh/authorized_keys
Output:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCtn5gMrv9p2G9y7Bt92ahtCxgWvXIjb1S/d+p31F+xlSYBuC9snBySQQQWmPdZrBbCAzRmdSHPR6KxKXblpj+DvpN68VPGkzUPatXXWLtlc1QjmWqvfNrBp+E/0mjcPSQSrZAWjxNw4zRRIUvmqBazMe75XbZsBpPXw7cS3wXr5pkDDDRM1SIihT3AnDj23S1haFEpnx1DrQEGf5EYvO6f7hirHXhXLNvegixBWY5z/jNim2yrmnj8qxv7z8vqc6tYMn6oiieijBI/Dw1HN/csf/e1DF4cM8Su3B31mR71eHqF+mLpIMCyHrC8h3Mhy3fnOA7DartwO1fRSKMjxyBN ubuntu@i-3992cc97
Ubuntu Generate SSH Key Video
The following video is demonstrating the process: