Create a linux VM on Azure and Connect using a Public Key
Seyi Lufadeju
Posted on November 5, 2024
Here’s a step-by-step guide to creating a Linux virtual machine (VM) on Microsoft Azure and connecting to it using SSH with a public key:
Step 1: Set Up Azure Account
- Log in to Azure: Go to Azure Portal and log in with your credentials.
- Subscription: Ensure you have an active subscription. If not, sign up for a free trial if you’re a new user.
Step 2: Create a Linux Virtual Machine on Azure
- In the Azure Portal, search for “Virtual Machines” in the search bar and select it.
- Click on "Create" > "Virtual machine".
Basics tab:
- Subscription: Select your subscription.
- Resource group: Create a new one or select an existing group.
- Virtual machine name: Enter a name for your VM (e.g., MyLinuxVM).
- Region: Choose a region close to you for better performance.
- Image: Select a Linux distribution (e.g., Ubuntu 20.04 LTS).
- Size: Choose an appropriate VM size based on your needs and budget.
- Authentication type: Select SSH public key.
- Username: Enter a username (e.g., azureuser).
- SSH public key source: Select Generate new key pair and download key pair
Inbound port rules:
- Public inbound ports: Select Allow selected ports.
- Select inbound ports: Choose SSH (22) to enable SSH access to the VM.
Configure Disk and Networking (optional):
By default, Azure will assign a public IP and necessary networking configurations for most basic setups.
Review and Create:
- Click on Review + create to review the configuration.
- After the validation, click Create to deploy your VM.
Connect to the Virtual Machine using powershell or command prompt:
input code: ssh -i (path to the key pair) (account username@ip address)
note: remove bracket from code
CONCLUSION
In conclusion, creating and connecting to a Linux virtual machine on Azure using SSH with a public key is a straightforward process. By following the steps outlined, you can set up a secure and accessible Linux environment in the cloud, allowing for remote management and scaling options as your needs grow. Generating an SSH key pair ensures your connection is secure, while configuring the VM in Azure’s portal provides a flexible setup tailored to your requirements. With Azure’s extensive features and scalable options, you’re now well-positioned to leverage this powerful platform for development, testing, or deployment of applications in a secure Linux environment.
Posted on November 5, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 27, 2024