---
# System prepended metadata

title: Lab

---

# Lab 

The most common way of connecting to a remote Linux server is through SSH. SSH stands for Secure Shell and provides a safe and secure way of executing commands, making changes, and configuring services remotely. When you connect through SSH, you log in using an account that exists on the remote server.


# Pre - Requisite 
Github

# Importance of SSH

We always communicating with either public or hybrid internet and to communicate across these type of internets SSH is the most secured way for the users. 

The most common daily life use is Github and to use the Git Services Github SSH is top priority. 

# Milestone 1 : Creating SSH Key with Github
1. Use the **ssh-keygen** command to create GitHub SSH key pairs:
```
github@ubuntu:~/.ssh$ ssh-keygen -o -t rsa -C "email@example.com"
```
It leads to generate the pair of keys which are **private key** `rsa`and **public key** `id_rsa.pub`.
Here is the sample output looks like after executing the above mentioned command: 

![](https://i.imgur.com/uf8NcZo.png)

# Milestone 2: Configuring SSH Key

1. Login to your github account and click on settings and you will see the `SSH and GPG Key option` as shown below:

![](https://i.imgur.com/wqwE1Tk.jpg)


2. Click the **New SSH** key:

![](https://i.imgur.com/qr0Q1yb.jpg)

3. Give it a name -- be short and descriptive -- and paste in the whole public key. This can either be id_rsa.pub. Then, click Save:

![](https://i.imgur.com/eHOJs6T.png)

# Milestone 3: Using SSH Key

Congratualtions on understanding how to create and configure SSH Key. Now we are on the Bingo part of understanding how to use the SSH key.

#### 1. You can use SSH key by copying your **Public Key**:
* If you do not have `ssh-copy-id` available, but you have `password-based` SSH access to an account on your server, you can upload your keys using a conventional SSH method.

* **Conventional Method**: we can make sure that the `~/.ssh` directory exists under the account we are using and then output the content we piped over into a file called `authorized_keys within this directory`.We will use the `>>` redirect symbol to append the content instead of overwriting it. This will let us add keys without destroying previously added keys.

**Syntax:** `cat ~/.ssh/id_rsa.pub | ssh username@remote_host "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"`

#### 2. Authorization of SSH Key using Single Sign On:

Once following the steps below the SSH Key stay authorized until revoked in one of the following ways:.

1. - [x] An organization or enterprise owner revokes the authorization.
2. - [x] You are removed from the organization.
3. - [x] The scopes in a personal access token are edited, or the token is regenerated.
4. - [x] The personal access token expired as defined during creation.

> Step 1. In the upper-right corner of any page, click your profile photo, then click Settings.

> Step 2. In the "Access" section of the sidebar, click  `SSH and GPG keys.`

> Step 3. Next to the SSH key you'd like to authorize, click Enable SSO or Disable SSO.
![](https://i.imgur.com/otZWknF.jpg)

> Step 4. Find the organization you'd like to authorize the SSH key for.

Step 5. Click Authorize.
![](https://i.imgur.com/2ardovK.jpg)

### Common Flags Used:
1. The **-o flag** forces the tool to generate SSH keys with the OpenSSH forma
2. The **-t flag** specifies they type of SSH keys to create
3. The **-C flag** allows for comments that get added as metadata at the end of the public key






