AWS Builder Center

Use Tailscale to Access Your AWS EC2 Instance

Information on how to use tailscale in EC2



If you create an EC2 instance and don't want to rely on its public IP address for SSH access, Tailscale provides a simple alternative.
Instead of connecting directly to the EC2 public IP, you connect to the instance through your private Tailscale network.

1. Create an EC2 Instance

Create your EC2 instance as usual.
You can run it without assigning a public IPv4 address if you have another way to initially install Tailscale, such as EC2 User Data or AWS Systems Manager.

2. Install Tailscale

On the EC2 instance, install Tailscale according to your Linux distribution.
For Amazon Linux, for example:
sudo yum install tailscale
Start the service:
sudo systemctl enable --now tailscaled
Then authenticate the instance:
sudo tailscale up
Follow the authentication URL and add the EC2 instance to your Tailscale network.

3. Install Tailscale on Your Computer

Install Tailscale on your laptop/desktop and sign into the same Tailscale account.
Once both machines are connected, they can communicate through Tailscale.

4. Get the EC2 Tailscale IP

On the EC2 instance:
tailscale ip
You'll get an address such as:
100.x.x.x
You can then SSH into the instance:
ssh ec2-user@100.x.x.x

5. Use MagicDNS

Instead of remembering the Tailscale IP, enable MagicDNS in Tailscale.
You can then connect using the machine's hostname:
ssh ec2-user@my-ec2
This is much more convenient when you have multiple servers.

The Result

Your setup becomes:
Your Laptop
│
│ Tailscale
│
▼
EC2
Rather than:
Your Laptop
│
│ Public Internet
│
▼
Public EC2 IP
│
▼
EC2
Tailscale effectively lets you treat your EC2 instance as another private machine on your network, making SSH and other internal services accessible without relying on the EC2 public IP.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article