Part A — Create the VM in Azure Portal
- Azure Portal
- Go to portal.azure.com
- Search: Virtual machines
- Click Create → Azure virtual machine
- Basics tab
- Subscription: choose your subscription
-
Resource group: Create new (example:
rg-devops-lab) -
Virtual machine name:
vm-lab-1 - Region: pick one (example: East US)
- Availability options: leave default (or “No infrastructure redundancy required” for simplest)
- Image: Ubuntu Server 24.04 LTS
-
Size: pick something small (example:
Standard_B1sorStandard_B2sif available)
- Administrator account (SSH)
- Authentication type: SSH public key
-
Username:
azureuser -
SSH public key source:
- Choose Generate new key pair (recommended if you don’t have one)
Key pair name:
vm-lab-1_key
- Inbound ports
- Select Allow selected ports
- Choose SSH (22)
- Click Review + create
- If validation passes, click Create
-
Azure will prompt to Download private key → download the
.pemfile- Save it safely (usually in
~/Downloads)
- Save it safely (usually in
Part B — Get the Public IP
- After deployment:
- Go to Virtual machines → open your VM
- Copy Public IP address (example:
20.x.x.x)
Part C — SSH from Mac Terminal
- Open Terminal and go to where the key is (example Downloads):
cd ~/Downloads
ls
- Fix permissions on the key (required):
chmod 400 vm-lab-1_key.pem
- Connect with SSH:
ssh -i vm-lab-1_key.pem azureuser@<PUBLIC_IP>
Example:
ssh -i vm-lab-1_key.pem azureuser@20.83.170.33
- First-time prompt:
- Type
yesand press Enter
You should land in:
azureuser@vm-lab-1:~$
Common problems (quick fixes)
1) Permission denied (publickey)
You forgot -i or used the wrong key:
ssh -i correct_key.pem azureuser@<PUBLIC_IP>
2) UNPROTECTED PRIVATE KEY FILE
Permissions are too open:
chmod 400 *.pem
3) SSH times out / hangs
Port 22 blocked:
- Azure Portal → VM → Networking
- Ensure Inbound rule allows TCP 22
- If you restricted Source to your IP, verify your current public IP
Top comments (0)