• Sales
  • My Account
  • Portal
Microsoft Azure Free trial
  • Features
    • What is Azure?
    • Compute

      Compute

      Virtual Machines
      Provision Windows and Linux Virtual Machines and applications in minutes
      Cloud Services
      Create highly available, infinitely scalable cloud applications and APIs
      Batch
      Run large-scale parallel and batch compute jobs
      Scheduler
      Run your jobs on simple or complex recurring schedules
      RemoteApp
      Deploy Windows client apps in the cloud, run on any device

      Get credits that enable:

      4 Windows or Linux VMs

      24 x 7 for a month

      And much more...

      Learn more

    • Web & Mobile

      Web & Mobile

      Websites
      Deploy and scale web apps in seconds
      Mobile Services
      Build and host the backend for any mobile app
      API Management
      Publish APIs to developers, partners and employees securely and at scale
      Notification Hubs
      Scalable, cross-platform push notification infrastructure

      Get credits that enable:

      Deploy 20 websites

      over 10M mobile API calls

      And much more...

      Learn more

    • Data & Storage

      Data & Storage

      SQL Database
      Managed Relational SQL Database-as-a-service
      DocumentDB
      Managed NoSQL document database-as-a-service
      Redis Cache
      High throughput, low latency data access to build fast and scalable applications
      Storage
      Durable, highly available and massively scalable cloud storage
      StorSimple
      Hybrid cloud storage for enterprises, reduces costs and improves data security
      Azure Search
      Fully-managed search-as-a-service

      Get credits that enable:

      8 standard SQL Databases

      Hadoop instance for a week

      And much more...

      Learn more

    • Analytics

      Analytics

      HDInsight
      Provision managed Hadoop clusters
      Machine Learning
      Powerful cloud-based predictive analytics
      Stream Analytics
      Real-time stream processing
      Data Factory
      Orchestrate and manage data transformation and movement
      Event Hubs
      Ingest, persist, and process millions of events per second

      Get credits that enable:

      8 standard SQL Databases

      Hadoop instance for a week

      And much more...

      Learn more

    • Networking

      Networking

      Virtual Network
      Provision private networks, optionally connect to on-premises datacenters
      ExpressRoute
      Dedicated private network fiber connections to Azure
      Traffic Manager
      Load balance incoming traffic for high performance and availability

      Connect Virtual Machines with Virtual Network for free.

      Learn more

    • Storage & Backup

      Storage & Backup

      Storage
      Durable, highly available and massively scalable cloud storage
      Backup
      Simple and reliable server backup to the cloud
      Site Recovery
      Orchestrate protection and recovery of private clouds

      Get credits that enable:

      Over 8 terabytes of storage

      Backup 700GB for a month

      And much more...

      Learn more

    • Media & CDN

      Media & CDN

      Media Services
      Encode, store, and stream video and audio at scale
      CDN
      Deliver content to end-users through a robust network of global data centers

      Get credits that enable:

      Encoding 100GB of media

      Transfer up to 1600GB of content

      And much more...

      Learn more

    • Hybrid Integration

      Hybrid Integration

      BizTalk Services
      Seamlessly integrate the enterprise and the cloud
      Service Bus
      Connect across private and public cloud environments
      Backup
      Simple and reliable server backup to the cloud
      Site Recovery
      Orchestrate protection and recovery of private clouds

      Get credits that enable:

      Send 200 million messages

      And much more...

      Learn more

    • Identity & Access Management

      Identity & Access Management

      Active Directory
      Synchronize on-premises directories and enable single sign-on
      Multi-Factor Authentication
      Safeguard access to your data and apps with an extra level of authentication

      Get credits that enable:

      Store 500,000 objects in Active Directory

      Multi-factor auth with 100 users

      And much more...

      Learn more

    • Developer Services

      Developer Services

      Visual Studio Online
      Plan, build and ship software, all from one place
      Application Insights
      Detect and solve problems to continuously improve web apps

      Each free account includes:

      Five free Basic licenses

      Unlimited private code repos

      And more!

      Learn more

    • Management

      Management

      Preview Portal
      Explore the new Azure Preview portal
      Scheduler
      Run your jobs on simple or complex recurring schedules
      Automation
      Simplify cloud management with process automation
      Operational Insights
      Collect, search and visualize machine data from on-premises and cloud

      Sign-up for free and get $200 to spend on all Azure services

      Learn more

    • Case Studies
  • Pricing
  • Documentation
  • Downloads
  • Marketplace
  • Blog
  • Community
    • Service Updates
    • Training
    • Events
    • Partners
      • Partner opportunity
      • Grow your business
      • Build your offering
      • Get started
    • Education
    • Newsletter
  • Support
    • Support Options
    • Support Plans
    • Forums
    • Service Dashboard
    • Trust Center
      • Overview
      • Security
      • Privacy
      • Compliance
      • Resources
      • FAQ
    • Legal
      • Overview
      • Subscription Agreement
      • Services Terms
      • Offer Details
      • Privacy Statement
      • Service Level Agreements
      • Preview Supplemental Terms
      • Store Terms
      • Website Terms Of Use
    • FAQ
Help us improve our documentation. Was this article helpful?
Yes No

Help us improve our documentation.

Was this article helpful?

Yes No
Help us improve our documentation. Rate this article.
Help us improve our documentation. Rate this article.
Tweet

Discover more resources for these services: Virtual Machines

Discover more resources: Python

Introduction to Linux on Azure

Updated:

This topic provides an overview of some aspects of using Linux virtual machines in the Azure cloud. Deploying a Linux virtual machine is a straightforward process using an image from the gallery.

Table of Contents

  • Authentication: Usernames, Passwords and SSH keys.
  • Generation and use of SSH keys for logging into Linux virtual machines.
  • Obtaining superuser privileges using sudo
  • Firewall configuration
  • Hostname changes
  • Virtual machine image capture
  • Attaching Disks

Authentication: Usernames, Passwords and SSH Keys

When creating a Linux virtual machine using the Azure Management Portal, you are asked to provide a username, password and (optionally) an SSH public key. The choice of a username for deploying a Linux virtual machine on Azure is subject to the following constraint: names of system accounts (UID <100) already present in the virtual machine are not allowed, 'root' for example.

  • See How to Use SSH with Linux on Azure

SSH Key Generation

The current version of the Management Portal only accepts SSH public keys that are encapsulated in an X509 certificate. Please follow the steps below to generate and use SSH keys with Azure.

  1. Use openssl to generate an X509 certificate with a 2048-bit RSA keypair.

    openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout myPrivateKey.key -out myCert.pem
    

    Please answer the few questions that the openssl prompts for (you may leave them blank). The content in these fields is not used by the platform.

  2. Change the permissions on the private key to secure it.

    chmod 600 myPrivateKey.key
    
  3. Convert the myCert.pem to myCert.cer (DER encoded X509 certificate)

    openssl  x509 -outform der -in myCert.pem -out myCert.cer
    
  4. Upload the myCert.cer while creating the Linux virtual machine. The provisioning process will automatically install the public key in this certificate into the ~/.ssh/authorized_keys file for the specified user in the virtual machine.

  5. Connect to the Linux virtual machine using ssh.

    ssh -i  myPrivateKey.key -p port  username@servicename.cloudapp.net
    

    You will be prompted to accept the fingerprint of the host's public key the first time you log in.

  6. You may optionally copy myPrivateKey.key to ~/.ssh/id_rsa so that your openssh client can automatically pick this up without the use of the -i option. Alternatively you can modify ~/.ssh/config to include a section for your virtual machine:

    Host servicename.cloudapp.net
      IdentityFile %d/.ssh/myPrivateKey.key
    

Generate a Key from an Existing OpenSSH Compatible Key

The previous example describes how to create a new key for use with Windows Azure. In some cases users may already have an existing OpenSSH compatible public & private key pair and wish to use the same keys with Windows Azure.

OpenSSH private keys are directly readable by the openssl utility. The following command will take an existing SSH private key (id_rsa in the example below) and create the .pem public key that is needed for Windows Azure:

# openssl req -x509 -key ~/.ssh/id_rsa -nodes -days 365 -newkey rsa:2048 -out myCert.pem

The myCert.pem file is the public key that may then be used to provision a Linux virtual machine on Windows Azure. During provisioning the .pem file will be translated into an openssh compatible public key and placed in ~/.ssh/authorized_keys.

Obtaining Superuser Privileges Using sudo

The user account that is specified during virtual machine instance deployment on Azure is a privileged account. This account is configured by the Azure Linux Agent to be able to elevate privileges to root (superuser account) using the sudo utility. Once logged in using this user account, you will be able to run commands as root using the command syntax

# sudo <COMMAND>

You can optionally obtain a root shell using sudo -s.

  • See Using root privileges on Linux virtual machines in Azure

Firewall Configuration

Azure provides an inbound packet filter that restricts connectivity to ports specified in the Management Portal. By default, the only allowed port is SSH. You may open up access to additional ports on your Linux virtual machine by configuring endpoints in the Management Portal:

  • See: How to Set Up Endpoints to a Virtual Machine

The Linux images in the Azure Gallery do not enable the iptables firewall by default. If desired, the firewall may be configured to provide additional filtering.

Hostname Changes

When you initially deploy an instance of a Linux image, you are required to provide a host name for the virtual machine. Once the virtual machine is running, this hostname is published to the platform DNS servers so that multiple virtual machines connected to each other can perform IP address lookups using hostnames.

If hostname changes are desired after a virtual machine has been deployed, please use the command

# sudo hostname <newname>

The Azure Linux Agent includes functionality to automatically detect this name change and appropriately configure the virtual machine to persist this change and publish this change to the platform DNS servers.

  • Azure Linux Agent User Guide

Ubuntu Images

Ubuntu images utilize cloud-init, which provides additional capabilities for bootstrapping a virtual machine.

  • See Custom Data and Cloud-Init on Microsoft Azure

Virtual Machine Image Capture

Azure provides the ability to capture the state of an existing virtual machine into an image that can subsequently be used to deploy additional virtual machine instances. The Azure Linux Agent may be used to rollback some of the customization that was performed during the provisioning process. You may follow the steps below to capture a virtual machine as an image:

  1. Run waagent -deprovision to undo provisioning customization. Or waagent -deprovision+user to optionally, delete the user account specified during provisioning and all associated data.

  2. Shut down/power off the virtual machine.

  3. Click Capture in the Management Portal or use the Powershell or CLI tools to capture the virtual machine as an image.

    • See: How to Capture a Linux Virtual Machine to Use as a Template

Attaching Disks

Each virtual machine has a temporary, local resource disk attached. Because data on a resource disk may not be durable across reboots, it is often used by applications and processes running in the virtual machine for transient and temporary storage of data. It is also used to store the page or swap files for the operating system.

On Linux, the resource disk is typically managed by the Azure Linux Agent and automatically mounted to /mnt/resource (or /mnt on Ubuntu images).

>[AZURE.NOTE] Note that the resource disk is a **temporary** disk, and might be deleted and reformatted when the VM is rebooted.

On Linux the data disk might be named by the kernel as /dev/sdc, and users will need to partition, format and mount that resource. This is covered step-by-step in the tutorial: How to Attach a Data Disk to a Virtual Machine.

  • See also: Configure Software RAID on Linux
Help us improve our documentation. Was this article helpful?
Yes No

Help us improve our documentation.

Was this article helpful?

Yes No
Help us improve our documentation. Rate this article.
Help us improve our documentation. Rate this article.

Contribute to this article

Want to edit or suggest changes to this content? You can edit and submit changes to this article using GitHub.

Need more help using this Azure service? Go to an MSDN forum or StackOverflow discussion

  • Go Social
  • Facebook
  • Twitter
  • Rss
  • Newsletter
  • Microsoft Azure
  • Features
  • Services
  • Regions
  • Case Studies
  • Pricing
  • Calculator
  • Documentation
  • Downloads
  • Marketplace
  • Microsoft Azure in China
  • Microsoft Azure Government
  • Community
  • Blogs
  • Service Updates
  • Forums
  • Events

  • Support
  • Forums
  • Service Dashboard
  • Support
  • Account
  • Subscriptions
  • Profile
  • Preview Features
  • Management Portal
  • Trust Center
  • Security
  • Privacy
  • Compliance
  • Hello from Seattle.
  • English (US)
    English (US) Čeština Dansk Deutsch
    English (India) English (UK) Español (ES) Suomi
    Français Ελληνικά Italiano Magyar
    Nederlands Bokmål Polski Português (BR)
    Português (PT) Svenska Română Türkçe
    Українська русский 日本語 한국어
    中文(简体) 中文(繁體)
     
  • USD
    US Dollar ($) Euro (€) Swiss Frank (chf) Argentine Peso ($)
    Australian Dollar ($) Danish Krone (kr) Canadian Dollar ($) Indonesian Rupiah (Rp)
    Japanese Yen (¥) Korean Won (₩) New Zealand Dollar ($) Norwegian Krone (kr)
    Russian Ruble (руб) Saudi Riyal (SR) South African Rand (R) Swedish Krona (kr)
    Taiwanese Dollar (NT$) Turkish Lira (TL) British Pound (£) Mexican Peso (MXN$)
    Malaysian Ringgit (RM$) Indian Rupee (₹) Hong Kong Dollar (HK$) Brazilian Real (R$)
     
  • Nutzungsbedingungen
  • Impressum
  • Contact Us
  • Trademarks
  • Privacy & Cookies
  • Feedback
Microsoft © 2014 Microsoft