[donotprint][/donotprint]You can use OpenSSH ssh client program for logging into a remote machine and for executing commands on a remote machine. The same client can be used to login into Amazon AWS EC2 instance powered by a CentOS Linux / Fedora / RHEL.
Create a Key Pair For a New EC2 Instance
- Login to your Amazon EC2 console at https://console.aws.amazon.com/ec2/.
- Select the region i.e. click US East (N. Virginia). (See fig.01)
- From the left navigation pane, click Key Pairs.
- Click Create Key Pair.
- Type “key name” (such as “centos-aws-db-1”) in the new Key pair name box, and then click Create. (See fig.02)
- Download the private key file, which is named centos-aws-db-1.pem, and keep it in a safe place. You will need it to access any instances that you launch with this key pair.
You need to use this key-pair for all your new instances. If you lose the key pair, you cannot connect to your Amazon EC2 instances.
Set private key permissions
Use the chmod command to make sure your private key file isn’t publicly viewable:
chmod 0400 ~/.ssh/centos-aws-db-1.pem
Connecting to Amazon EC2 Instance from a RHEL/CentOS Linux/UNIX/OSX Using a SSH Client
The syntax is as follows:
ssh -i key-file-name-here.pam ec2-user@public-dns-name
In this example, I’m connecting using the key ~/.ssh/centos-aws-db-1.pem file, ec2-user name and the instance’s DNS name is ec2-54-211-235-9.compute-1.amazonaws.com:
ssh -i ~/.ssh/centos-aws-db-1.pem firstname.lastname@example.org
SSH user names for various Linux distros
- For Amazon Linux, the default user name is ec2-user.
- For CentOS/RHEL, the user name is often root or ec2-user.
- For Ubuntu, the user name is ubuntu.
- For SUSE Linux, the user name is root.
- Also, check with your AMI provider for username.