Access EC2 without pem file with with username and password


Access EC2 without pem file with with username and password

Sometimes you need to grant permissions to someone else and maybe you don’t want to share the .pem file. By default, the ssh access is granted through a .pem file by Amazon EC2.

  1. You can create your own user and access the server using a password. In order to set up this, firstly first let’s login on the server as usual
$ ssh -i pem_file.pem ubuntu@ec2- ________.compute-1.amazonaws.com
  1. Create a new user
$ sudo useradd -s /bin/bash -m -d /home/USERNAME -g root USERNAME
  1. Add a password
$ sudo passwd USERNAME
  1. Add users to sudoers
$ sudo visudo

Here you need to add the following line

USERNAME ALL=(ALL:ALL) ALL
  1. Enable the access by password through ssh
$ vi /etc/ssh/sshd_config

Here you need to search PasswordAuthentication from no to yes.

  1. Restart ssh
$ sudo /etc/init.d/ssh restart
  1. Connect to the server using the new user
$ ssh USERNAME@ec2- ________.compute-1.amazonaws.com

This is all.

If you consider this tutorial was useful please let me a comment or share the article. For any suggestions or comments, please drop me a line below.

Newsletter


Related Posts

Tools for Analyzing Your Competition

Before knowing where your business stands, you should look at the market and your competition. You need to know what marketing tactics and strategies are working for your audience, what traffic the competition has, and how they position.

Free Online Photo Editor with Cool Effects | Edit Images Easily

Transform your images with our free online photo editor with cool effects. Add filters, adjust colors, and apply creative enhancements. Edit your photos easily and make them stand out.

How to find the size of a table in SQL?

Learn how to determine the size of a SQL table with this informative guide. Discover efficient methods for measuring table size.

MongoDB Query date by _id field

Query date by _id in mongodb. Straighforward guide to solve your issue right away.

Unleashing the Power of Free API for Scrape Reverse Geocoding

Learn how to harness the potential of reverse geocoding with our beginner's guide to scraping APIs for free. Unlock the power today.

Discover the Power of Whatsapp-web.js for Safe and Easy Automation

Automate WhatsApp with ease using Whatsapp-web.js, a NodeJS client library that connects through the official WhatsApp Web app, reducing ban risks. Perfect for user or business accounts.

Website tours js tools

Tools to create live tours for your web project using js libraries.

Unlocking SaaS Marketing Success: Essential Resources to Learn and Grow

Discover a comprehensive collection of valuable resources to master the art of SaaS marketing.

Where to launch your startup

Do you wanna launch grandiosely your startup? Get a list of platforms where people can discover your project and can push your project directly to the sky.

Email campaign improving my SaaS convertion - Manager Flota

Users subscribe to your SaaS, but don't let the money on your table. Here's how I do it!