Authentication into Virtual machines
- Linux Operating Systems:
- Password Based Authentication
- Key Based Authentication
- Windows Operating Systems:
- Password Based Authentication
AWS
- AWS By default allows only key based authentications
Azure
- Azure supports both key based and password based authentications
What is key based authentication (SSH)
- We create a key pair:
- private key
- public key
- While login in to servers we will have private key and server will have public key
- We can generate a key pair in your system by executing
ssh-keygena key pair will be created in<home-dir>/.ssh/with keysid_rsawhich is private key andid_rsa.pubwhich is public key - AWS also generates a key pair, in this cases aws will store public key and gives you back the private key with
.pemextension - Azure also generates a key pair, in this cases Azure will store public key and gives you back the private key with
.pemextension - Both AWS and Azure also support importing your public keys
Activity 1: Create a key pair from AWS
- Steps: Navigate to key pairs in EC2 dashboard (Region of your choic)
Activity 2: Import a public key into AWS
- Navigate to keypairs and import
Activity 3: Create a key pair from Azure
- In Azure we have a service called as ssh_keys
Activity 4: Import a public key into Azure
- We can also import our key
Distributions in Linux
Activity 5: Create a ubuntu 22.04 based ec2 instance with public ip
- my choices:
- region: mumbai
- size: t2.micro
- keypair: my_idrsa
- vpc: default
- subnet: any
- security group (creating a security group)
- Security group: will have only 22 port opened and can be accessed from anywhere (0.0.0.0/0)
- Create an ec2 instance
- In AWS, AMI i.e. image will have a default user
- ubuntu AMIs => ubuntu
- redhat AMIs => ec2-user
- Amazon AMIs => ec2-user
- Windows AMIs => administrator
Activity 6: create a redhat 9 based ec2 istance with public ip
- my choices:
- region: mumbai
- size: t2.micro
- keypair: mumbai
- vpc: default
- subnet: any
- security group (use the one created above)
- For guided creation watch classroom video
Activity 7: Create a Ubunu 24.04 in azure
- Refer Here for steps
- my choices:
- region: eastus
- size: B1s
- keypair: my_idrsa
- virtual network: created by default with virtual machine
- subnet: create by default with virtual machine
-
network security group (select options to create by default with virtual machine)
-
Exercise:
- Create a amazon linux instance and ssh into it
- create a redhat vm in azure and ssh into it
SSH Command
- SSH two well known ways
- with username and password
ssh username@<ipaddress> - with username and key
ssh -i <path to private key> username@ipaddress - with username and default key
~/.ssh/id_rsassh username@ipaddress
- with username and password
