How to Create a Shorter Alias for Public DNS Hostname

After you’ve created your Amazon EC2 instance, set up Security Groups for ssh, set up your key pair, you will realize that your Public DNS for your EC2 instance is super long and very hard to remember. You also wish you could exclude having to type the "username@" prefix when you ssh to the server.

At this point you wish you could create a shorter name (alias) for it, right? Well you can!

One solution is to add to your ~/.ssh/config file something like the following to create your alias to your Public DNS:

Host ec2
  Hostname ec2-x-x-x-x.compute-x.amazonaws.com
  User ubuntu

The Host ec2 is the alias. You can call it whatever you like.

Replace the sample Hostname with yours. You can see what your Public DNS is by looking in your EC2 Navigation pane, in the Description tab.

Replace ubuntu above with the username the instance you’re using has available.

In order to ssh to your Public DNS, you can do the following:

ssh ec2

instead of having to do this:

ssh ubuntu@ec2-x-x-x-x.compute-x.amazonaws.com
VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
Facebook Twitter Email

Leave a Reply