SSH server in most systems is by default configured to allow public-key authentication. The method will enable you to use your public and private key pair to passwordless log in to an SSH server instead of the typical username and password method.
How to connect aws without public key or Password?
The AWS Systems Manager console includes access to all the Session Manager capabilities for both administrators and end users. You can perform any task that is related to your sessions by using the Systems Manager console. we will connect on the terminal using ssh. and now we need to know about IAM. IAM help us to communicate server and session manager.
IAM :Through the use of IAM policies, you can control which members of your organization can initiate sessions to managed nodes and which nodes they can access. You can also provide temporary access to your managed nodes.
Let’s see how to do it? 1st of all go to the ec2 control panel and click on the action button. then you will get the security option> modify IAM role. click on the Modify IAM role.
create a new IAM role. select aws service and ec2. now click on the next
and find a policy “AmazonSSMManagerInstanceCore”. select this role and click next.
Give a name of the role and description. and click on the create role button
How to connect ec2 instance in Session manager?
Now we search session manager from aws console. you need to wait 10 minutes before start the session. after 1o minutes, you would have to selcet the server and start a session. the you will get command line access in session manager. but not root user. you have to write a command for a user. the command is:
sudo su -
Now you will get root user access and you can perform any task as a root user.
How to enable Password Authentication?Gi
you have to edit sshd_config file. the file path “etc>ssh>sshd_config” . so need to open it on a notepad. we use a nano note pad. if not have nano editor on your linux just runt this command. “sudo apt-get install nano”
let’s do our main task. 1st of all open the sshd_congig file. using the command bellow
sudo nano /etc/ssh/sshd_config
Lookup the variable: PermitRootLogin and PasswordAuthentication option change ‘no’ to ‘yes’
PermitRootlogin yes
PasswordAuthentication yes
Save and close the file. Run this command:
service sshd reload
Now you will be able to SSH into your server without public keys.
Make sure your other authentication method such as password is enabled before disabling public key authentication method as you might completely lose remote access to your server. so ensure you know the linux password.