How to Spin Up a Remote Server on AWS: Complete Guide
By Braincuber Team
Published on April 10, 2026
AWS is made up of discreet building blocks that you can use to build complex infrastructure. When you are just starting out, you need to know foundational concepts like how to get your server IP address and which SSH key to use. This complete tutorial walks you through everything you need to spin up your first remote server on AWS cloud.
What You'll Learn:
- Key AWS concepts: EC2, Security Groups, Key Pairs, and VPC
- Step by step guide to launching EC2 instances via AWS console
- Beginner guide to configuring security groups for access
- How to connect to your remote server using SSH
- Complete tutorial on launching EC2 with Python boto3 library
- Essential server administration tips for AWS cloud
Key AWS Concepts for Server Administration
Before spinning up your first remote server, you need to understand some foundational AWS terms. These concepts are directly applicable to launching remote servers and are also used for more complex infrastructure services like Elastic Beanstalk, Docker Swarm, and Kubernetes.
Elastic Compute Cloud (EC2)
AWS EC2 instances are where compute power lives. These are your remote servers. Knowing how to deal with EC2 instances is incredibly important because they appear just about everywhere in AWS architecture.
Security Groups
Security groups are what allow access to your various AWS services, including EC2 instances. They define which ports are open for inbound and outbound traffic. Security groups act as a virtual firewall for your instance.
Key Pairs
Key pairs are your SSH keys for secure access to instances. Keep track of these and store them somewhere safe. If you use AWS frequently, you will accumulate key pairs, so give them descriptive names instead of generic names like "ssh".
Important
Always keep your key pair secure and never share it. Anyone with access to your key pair can connect to your EC2 instances.
Virtual Private Cloud (VPC)
A VPC is an isolated resource where your compute infrastructure lives. Think of the VPC as the container or "Lego box" while EC2 instances, Security Groups, and Key Pairs are the actual building blocks. VPCs take care of all your networking. When you sign up for an AWS account, you get a default VPC.
EC2 Instances
Virtual servers in the cloud that provide compute capacity for your applications.
Security Groups
Virtual firewalls controlling inbound and outbound traffic for your instances.
Key Pairs
SSH key pairs for secure authentication to your remote servers.
VPC
Virtual network environment isolating your AWS resources.
How to Launch an EC2 Instance Using the Console
There are many ways to launch an EC2 instance. Today we will go over using the AWS web console. If you are ever lost, just search for your service from the Services Menu.
Navigate to EC2 Dashboard
Step by step guide:
- Log in to your AWS Console
- Click on Services to bring up the search box
- Type in EC2 to find the Elastic Compute Cloud service
- Click on EC2 from the menu to go to the dashboard
Launch Instance Wizard
Once at the EC2 Dashboard, click the Launch Instance button. The AWS EC2 Launch Wizard will walk you through 7 steps to configure your instance.
Select Your AMI Type
Choose your operating system and preconfigured image. Popular options include:
- Amazon Linux 2 - Recommended for AWS workloads
- Ubuntu - Popular for web servers
- CentOS - Enterprise-friendly Linux
- Bitnami images - Pre-configured for WordPress, Nginx, Ghost
Choose Instance Type
Select the compute capacity you need. Options range from small t2.micro instances to powerful compute-optimized instances. For learning, use the free tier eligible t2.micro.
Instance Types Overview
| Instance Family | Use Case | Example |
|---|---|---|
| T2/T3 | General purpose, low cost | t3.micro, t2.micro |
| M5 | Balanced compute and memory | m5.large |
| C5 | Compute optimized | c5.xlarge |
| R5 | Memory optimized | r5.large |
Add Tags to Your Instance
Tags help you identify and organize your AWS resources. At minimum, add a Name tag to your instance. This makes it easier to find instances and create resource groups.
Configure Security Group
Security groups define access rules. The default opens port 22 for SSH. For web applications, you may need to open:
- Port 22 - SSH access
- Port 80 - HTTP web traffic
- Port 443 - HTTPS secure traffic
- Port 3306 - MySQL database access
Launch and Select Key Pair
Click Review and Launch. Select an existing key pair or create a new one. Download the .pem file and store it securely. You will need this to connect to your instance via SSH.
How to Connect to Your EC2 Instance via SSH
Once your instance is running, you can connect to it using SSH. The commands differ slightly depending on which OS you chose.
# First, set correct permissions on your key file
chmod 400 ~/.ssh/my-remote-server.pem
# Connect to Amazon Linux 2 instance
ssh -i ~/.ssh/my-remote-server.pem ec2-user@PUBLIC_DNS
# Connect to Ubuntu or Bitnami instance
ssh -i ~/.ssh/my-remote-server.pem ubuntu@PUBLIC_DNS
Note
The PUBLIC_DNS can be found in your EC2 dashboard. Look for the Public DNS (IPv4) column for your running instance.
Launch EC2 with Python boto3 Library
For programmatic access, you can use the Python boto3 library to launch EC2 instances. While for production you would typically use infrastructure as code tools like CloudFormation or Terraform, using boto3 helps you understand the foundations.
Required Python Packages
pip install boto3 paramiko
Complete boto3 Script for Launching EC2
import boto3
import time
import json
import os
PROJECT = "my-remote-server"
KEY_PAIR = "my-remote-server"
SECURITY_GROUP = "sg-some-number"
AMI_ID = "ami-062f7200baf2fa504"
INSTANCE_TYPE = "t3a.medium"
def create_key_pair():
ec2_client = boto3.client('ec2')
key_pair_response = ec2_client.create_key_pair(KeyName=KEY_PAIR)
return key_pair_response
def write_key_file(key_material, filename):
with open(filename, 'w') as f:
f.write(key_material)
os.chmod(filename, 0o400)
def create_instance():
ec2 = boto3.resource('ec2')
instance = ec2.create_instances(
SecurityGroupIds=[SECURITY_GROUP],
ImageId=AMI_ID,
MinCount=1,
MaxCount=1,
InstanceType=INSTANCE_TYPE,
KeyName=KEY_PAIR,
TagSpecifications=[{
'ResourceType': 'instance',
'Tags': [{'Key': 'Name', 'Value': PROJECT}]
}]
)
return instance[0]
def get_public_ip(instance):
print('Waiting for instance to initialize...')
instance.wait_until_running()
instance.reload()
return instance.public_ip_address
initialize_dir()
key_pair = create_key_pair()
key_file = os.path.join(KEY_PAIR, 'keypair.pem')
write_key_file(key_pair['KeyMaterial'], key_file)
instance = create_instance()
public_ip = get_public_ip(instance)
print(f'SSH Command: ssh -i {key_file} ec2-user@{public_ip}')
Best Practices for AWS Server Administration
Secure Your Key Pairs
Never share your private keys. Store them securely and set proper file permissions (chmod 400).
Use Descriptive Names
Give your key pairs and instances descriptive names for easier management and identification.
Tag Everything
Use tags to organize resources by project, environment, or team for better cost tracking and management.
Restrict Security Groups
Only open ports you need. Never leave unnecessary ports open to the internet.
Frequently Asked Questions
What is the difference between SSH username for different AMIs?
Amazon Linux 2 uses "ec2-user", Ubuntu uses "ubuntu", and Bitnami images typically use "bitnami" as the default SSH username.
How do I find my EC2 instance public IP address?
Go to the EC2 Dashboard, select your instance, and look for "Public IPv4 address" or "Public DNS (IPv4)" in the details panel at the bottom.
What permissions should my SSH key file have?
Your private key file should have permissions set to 400 (read-only for owner only). Use chmod 400 ~/.ssh/your-key.pem to set the correct permissions.
Can I launch EC2 instances programmatically?
Yes, you can use AWS SDKs like boto3 for Python, the AWS CLI, or infrastructure as code tools like CloudFormation and Terraform for programmatic instance creation.
What ports should I open in my security group?
Open only the ports you need: port 22 for SSH (restrict to your IP), port 80 for HTTP, port 443 for HTTPS, and database ports only if absolutely necessary.
Need Help with AWS Server Administration?
AWS EC2 and server administration can be complex when you are just starting out. We help businesses set up, configure, and manage their AWS infrastructure. From launching your first EC2 instance to building complex architectures, we have the expertise to help you succeed.
