| author | sdwheeler |
|---|---|
| description | Learn how to use the Bash command line in your browser with Azure Cloud Shell. |
| manager | mkluck |
| ms.author | sewhee |
| ms.contributor | jahelmic |
| ms.date | 11/14/2022 |
| ms.service | cloud-shell |
| ms.tgt_pltfrm | vm-linux |
| ms.topic | article |
| ms.workload | infrastructure-services |
| tags | azure-resource-manager |
| title | Quickstart for Bash in Azure Cloud Shell |
This document details how to use Bash in Azure Cloud Shell in the Azure portal.
Note
A PowerShell in Azure Cloud Shell Quickstart is also available.
-
Launch Cloud Shell from the top navigation of the Azure portal.
-
Select a subscription to create a storage account and Microsoft Azure Files share.
-
Select "Create storage"
Tip
You are automatically authenticated for Azure CLI in every session.
Check that the environment drop-down from the left-hand side of shell window says Bash.
-
List subscriptions you have access to.
az account list -
Set your preferred subscription:
az account set --subscription 'my-subscription-name'
Tip
Your subscription is remembered for future sessions using /home/<user>/.azure/azureProfile.json.
Create a new resource group in WestUS named "MyRG".
az group create --location westus --name MyRG
Create an Ubuntu VM in your new resource group. The Azure CLI will create SSH keys and set up the VM with them.
az vm create -n myVM -g MyRG --image UbuntuLTS --generate-ssh-keys
Note
Using --generate-ssh-keys instructs Azure CLI to create and set up public and private keys in
your VM and $Home directory. By default keys are placed in Cloud Shell at
/home/<user>/.ssh/id_rsa and /home/<user>/.ssh/id_rsa.pub. Your .ssh folder is persisted in
your attached file share's 5-GB image used to persist $Home.
Your username on this VM will be your username used in Cloud Shell ($User@Azure:).
-
Search for your VM name in the Azure portal search bar.
-
Select Connect to get your VM name and public IP address.
-
SSH into your VM with the
sshcmd.ssh username@ipaddress
Upon establishing the SSH connection, you should see the Ubuntu welcome prompt.
-
Exit your ssh session.
exit -
Delete your resource group and any resources within it.
az group delete -n MyRG


