Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

How to Generate SSH Keys in Azure

Cloud (Windows/Linux)

[Edition 01]

[Last Update 200331]

For any issues/help contact : support@k21academy.com

support@k21academy.com 1
1 Introduction .........................................................................................................................................................3
2 Documentation Links ........................................................................................................................................4
3 Generate SSH Keys (Public & Private).........................................................................................................5
3.1 Generate SSH Private & Public Keys using PuttyGEN..................................................................................... 5
3.1.1 Download PuttyGen Software .......................................................................................................................................... 6
3.1.2 Generate Keys on Windows Laptop/Desktop ........................................................................................................... 6
3.1.3 Generate SSH Keys on MAC .............................................................................................................................................11
4 Creating an SSH Key Pair on Linux ............................................................................................................ 13
5 SUMMARY ........................................................................................................................................................... 14

support@k21academy.com 2
1 INTRODUCTION

This activity guide cover steps to Generate SSH Keys In Azure Cloud (Windows/Linux) For
Microsoft AZ-103 Training.

This Guide Covers,

• Generate SSH Keys


• Connect to Unix Server on Cloud using Putty/Terminal

support@k21academy.com 3
2 DOCUMENTATION LINKS

1. Generate SSH Keys for Linux, Mac or Windows


https://docs.oracle.com/en/cloud/paas/database-dbaas-cloud/csdbi/generate-ssh-key-
pair.html#GUID-4285B8CF-A228-4B89-9552-FE6446B5A673
2. Download Putty http://www.putty.org
3. Download PuttyGenhttp://puttygen.software.informer.com/download/

support@k21academy.com 4
3 GENERATE SSH KEYS (PUBLIC & PRIVATE)

Note: Steps in this section are applicable only for cloud services for which you need to
connect to Linux Machine on Cloud using SSH

Before you can create Linux instance on Cloud, You must generate SSH Key Pair
(Private & Public Keys) so that you can connect to Linux Machine.
Public Key will be uploaded on Microsoft Cloud Server while private key must be
kept safe with you.

3.1 Generate SSH Private &


Public Keys using PuttyGEN

In this section we generate Keys with puttygen (Utility to connect to Unix server)
from and
a) When we create Linux Instance, you provide public key. (It is OK to share Public
Key but never share Private Key)

support@k21academy.com 5
b) Future connection from local Laptop/PC is securily done over SSH and is
Authenticated using Private/Public Key pair.
Depending on operating system of your laptop or desktop (Windows or Mac)
refereresepective section to generate SSH Private and Public Keys.

3.1.1 DOWNLOAD PUTTYGEN SOFTWARE


Download Puttygen Software from any one of the following locations
1) https://k21academy.com/puttygen
Install PuttyGen Click “Run PuttyGen.

3.1.2 GENERATE KEYS ON WINDOWS LAPTOP/DESKTOP

Note: If you are on Mac then check steps later in this section

1. Open PuttyGen, it will show like below:

2. Click on Generate

support@k21academy.com 6
1. To generate the keys, Click on Generate and hover your mouse around the area
blank area randomly as shown:

support@k21academy.com 7
2. There will be a key generated in the blank box,as shown below.
3. Click on Save private key button to save the private key in your system. Add the key
passphrase (Password) and re-enter it again to confirm passphrase.
4. For public key, first copy and paste the Key content in some other file from the shown
window as sometimes it shows issue while accepting public key file.
5. In that case we can use the copied key content. After that click on Save Public Key to
save the file and save at the same location where you have saved private key in your
system.

Note:We can also save private key without passphrase but for security reasons you
can enter passphrase. (In production you must use passphrase to protect your
private key).
Note: Public key format start with ssh-rsa & end with rsa-key-20190314

support@k21academy.com 8
After generating and saving both the keys, you can go back to the Cloud Portal.

6. The public Key generated is copy and paste in “SSH Public Key” Section on azure
portal.

support@k21academy.com 9
7. This will generate Private & Public Key, Save them to your Laptop/Desktop

Note: Make a note of these two keys as you will need public key in next Activity
Guide.

support@k21academy.com 10
3.1.3 GENERATE SSH KEYS ON MAC

If you are on Mac and using Terminal (and not Putty) then follow
https://www.siteground.com/kb/how_to_generate_an_ssh_key_pair_in_mac_os/

support@k21academy.com 11
Note: Make a note of these two keys as you will need public key in next Activity
Guide.

This is how the Private key will look like in MAC:


cat id_rsa
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc
2gtcnNhAAAAAwEAAQAAAQEAzwHbcJKW6YgRWcIKL351qxWRFLHjvF9+oFyw9rRw44v
97g4vrO4b3188A7mT090vyht+EhkH5t5jSBrhc0oxDt2nSNGyJmiY28nwdUAxNQf7PSKKzIs
iNNxQICWfYFEZVpoPjwkM81xK2oAStcNFv7PgPHgkVoH77+ceBzp9gqJRfGOxbA3Ld2gq
R6IvfWkFIkDDbubUT2m1gRW6Y6qsxgRn7/DgWySbIYOn+MJ5JqWTzFswyKproUK82oyk
AUpjwFdeCEHKpsn8aYm22LyIQ0nHMZCcDprKrewAruLb4erXKtII6+BSYIgS3W4znRK7O
qYFDBF3Zw8SjqhL/b7yUQAAA+BWbNaHVmzWhwAAAAdzc2gtcnNhAAABAQDPAdtwkpb
piBFZwgovfnWrFZEUseO8X36gXLD2tHDji/3uDi+s7hvfXzwDuZPT3S/KG34SGQfm3mNIG
uFzSjEO3adI0bImaJjbyfB1QDE1B/s9IorMiyI03FAgJZ9gURlWmg+PCQzzXEragBK1w0W/
/c1tPOUPpRFK8DFbtVdr3jWdXkty3TyXfYXiRHkrB2A+0UrZ//4mowXQ3ajzbZxMg/84uD6A
AAAgQDuPTZrnyMgFZwDYFdhLPTOme+6YUEPL628B0QlWhFGNQipjwYlcfH1i7UqFJDJt
OfcQEhG2ATgunVqoikJ/l/H6TAxwb6ggo77YG53orcfu2WrE9UV0g+egryUczgg1udDr5Yan
bIrI5CRsTBkKE9MdppkXJV2T4aysljLta9whQAAAIEA3nCV3Saq/JvqINhEEcrhrYK9IsOAnH
LyVsR7sIjP/6sqcRbVDzyKEd8tb1TXbjo6lNvdDb2XvycTX2gcX9W6pS7xWxxQRWvyIfXfzw
NlvbqFc2Wk6j+E/rBo43ZeO2itxmvrHeCWcLyBaCkPI5PxifaO6/b5Cpbu5FCZUfh8al0AAAA
ka2h1c2hib29AS2h1c2hib29zLU1hY0Jvb2stQWlyLmxvY2FsAQIDBAUGBw==
-----END OPENSSH PRIVATE KEY-----

This is how Public Key will look like in MAC


catid_rsa.pubssh-rsa
AAAAB3NzaC1yc2EAAAADAQABAAABAQDPAdtwkpbpiBFZwgovfnWrFZEUseO8X36gXL
D2tHDji/3uDi+s7hvfXzwDuZPT3S/KG34SGQfm3mNIGuFzSjEO3adI0bImaJjbyfB1QDE1B/
s9IorMiyI03FAgJZ9gURlWmg+PCQzzXEragBK1w0W/s+A8eCRWgfvv5x4HOn2ColF8Y7Fs
Dct3aCpHoi99aQUiQMNu5tRPabWBFbpjqqzGBGfv8OBbJJshg6f4wnkmpZPMWzDIqmuh
QrzajKQBSmPAV14IQcqmyfxpibbYvIhDSccxkJwOmsqt7ACu4tvh6tcq0gjr4FJgiBLdbjOdEr
s6pgUMEXdnDxKOqEv9vvJR Atul@Atul-MacBook-Air.local

support@k21academy.com 12
4 CREATING AN SSH KEY PAIR ON LINUX

1) Open a shell or terminal for entering the commands.

2) At the prompt, enter ssh-keygen and provide a name and passphrase when prompted.

The keys will be created with the default values: RSA keys of 2048 bits.

Alternatively, you can type a complete ssh-keygen command. For example:

ssh-keygen -t rsa -N "" -b 2048 -C "<key_name>" -f <path/root_name>

support@k21academy.com 13
5 SUMMARY
This completes step by step guide covering:
• Generate SSH Keys Pair for Windows & Linux

support@k21academy.com 14

You might also like