DEV Community

Chukwuka Samson
Chukwuka Samson

Posted on • Edited on

A Step-by-Step Guide to Using Local Terminals Like Bash for Seamless SSH Connections

Remote access to virtual instances has become a crucial skill for developers, system administrators, and anybody managing cloud-based infrastructure as cloud computing gains popularity. Two popular ways to access your EC2 instances are provided by Amazon Web Services (AWS): SSH utilizing local terminals and browser access. In this blog post, we'll look at how to easily take complete control of your EC2 instances using local terminals.

For maintaining and remotely accessing servers, including Amazon EC2 instances, Secure Shell (SSH) is a vital tool. Developers and system administrators can easily manage their cloud-based infrastructure by becoming experts at SSH connections utilizing local terminals like Bash.

Step 1: Obtain Your Key Pair
Make sure you have an SSH key pair before starting any SSH connections. You ought to have established a key pair in the AWS dashboard when setting up the EC2 instance. Create a new key pair in the AWS EC2 console if you don't already have one, and then safely store the private key (for example, "key.pem") on your computer.

Step 2: Locate the Public IP Address
Locate the public IP address of your EC2 instance, which serves as the gateway for remote connections, in the AWS EC2 console. For further usage, write down the public IP address.

Step 3: Configure the Private Key's Permissions
Restricting access to your private key on your local machine is crucial for keeping it secure. Use the following command to launch your terminal (Bash):

/path/to/your/key.pem chmod 400

The real path to your private key should be used in place of "/path/to/your/key.pem".

Step 4: Establish the SSH Connection
You are now prepared to connect to your EC2 instance since the key permissions have been set. The following SSH command should be entered into your terminal (Bash):

ssh -i /path/to/your/key.pem ubuntu@<public-ip-address>

Put the real path to your private key in place of "/path/to/your/key.pem" and your EC2 instance's public IP address in place of "". The default user for Ubuntu-based EC2 instances is represented by the word "ubuntu" in the command. Use the correct username for the other distributions (e.g., "ec2-user" for Amazon Linux).

Step 5: Accept the SSH Key Fingerprint
The terminal will ask you to confirm the host's legitimacy during the initial connection attempt by presenting the ECDSA key fingerprint. Review the fingerprint, then press "yes" to move forward.

Step 6: Successful Connection
Congratulations! If everything went according to plan, you should now be using SSH in your local terminal (Bash) to connect to your EC2 instance. Now that orders and actions can be carried out as though they were being done directly on the server.

Step 7: Disconnecting from the EC2 Instance
Simply enter the command "exit" in the terminal to end the SSH session and go back to your local computer when you are finished with your chores on the EC2 instance.

Any developer or system administrator working with cloud-based infrastructure must be able to establish SSH connections using local terminals like Bash. You can securely login to your Amazon EC2 instances and effectively manage them with the help of this step-by-step manual. You may expedite your cloud operations and concentrate on creating reliable applications and services by taking advantage of SSH's secure and adaptable features. In order to fully realize the possibilities of your cloud journey, embrace SSH's power and let it be your key. Cloud computing success!

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay