Home
%3CLINGO-SUB%20id%3D%22lingo-sub-1085251%22%20slang%3D%22en-US%22%3EDetermining%20the%20public%20IP%20address%20of%20your%20CloudShell%20session%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1085251%22%20slang%3D%22en-US%22%3E%3CP%3ECloudShell%20is%20a%20great%20tool%20for%20performing%20command%20line%20work%20against%20resources%20in%20Azure.%20One%20of%20the%20challenges%20around%20using%20CloudShell%20to%20remotely%20SSH%20or%20use%20PowerShell%20Remoting%20into%20IaaS%20VM%20resources%2C%20especially%20when%20you%20have%20a%20locked%20down%20configuration.%20This%20is%20because%20each%20time%20you%20start%20a%20new%20CloudShell%20session%2C%20a%20container%20is%20spun%20up%20to%20host%20that%20session.%20This%20container%20is%20assigned%20a%20new%20private%20and%20public%20IP%20address.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20are%20requesting%20a%20Just%20in%20Time%20session%20to%20a%20VM%2C%20you%20need%20to%20know%20the%20IP%20address%20that%20you%20are%20going%20to%20grant%20access%20to.%20The%20connection%20will%20use%20the%20CloudShell%20session%E2%80%99s%20public%20IP%20address%2C%20which%20means%20you%20need%20to%20know%20that.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%E2%80%99ve%20played%20around%20with%20CloudShell%2C%20you%20know%20that%20you%20can%20determine%20the%20local%20IP%20address%20of%20the%20container%20that%20hosts%20your%20cloudshell%20session%20using%20ifconfig%20-a%20as%20shown%20in%20the%20exhibit.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F163512iA23D04CA93B9216C%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22clipboard_image_0.png%22%20title%3D%22clipboard_image_0.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EUnfortunately%20this%20doesn%E2%80%99t%20help%20when%20it%20comes%20to%20determining%20the%20remote%20IP%20address.%20Luckily%20you%20can%20determine%20the%20public%20IP%20address%20assigned%20to%20the%20CloudShell%20session%20using%20the%20following%20command%20as%20shown%20in%20the%20exhibit%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Ecurl%20-s%20checkip.dyndns.org%20%7C%20sed%20-e%20's%2F.*Current%20IP%20Address%3A%20%2F%2F'%20-e%20's%2F%26lt%3B.*%24%2F%2F'%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F163513iD34D48C33BB455F0%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22clipboard_image_1.png%22%20title%3D%22clipboard_image_1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EOnce%20you%20have%20this%20public%20IP%20address%2C%20you%20can%20use%20it%20when%20configuring%20your%20JiT%20session%2C%20or%20when%20creating%20a%20temporary%20NSG%20rule.%20This%20allows%20you%20to%20have%20remote%20access%20to%20your%20IaaS%20VM%20from%20CloudShell%20without%20creating%20a%20rule%20that%20allows%20remote%20access%20to%20every%20public%20IP%20address%20that%20is%20available%20to%20Azure%20hosts.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1085251%22%20slang%3D%22en-US%22%3E%3CP%3ECloudShell%20is%20a%20great%20tool%20for%20performing%20command%20line%20work%20against%20resources%20in%20Azure.%20One%20of%20the%20challenges%20around%20using%20CloudShell%20to%20remotely%20SSH%20or%20use%20PowerShell%20Remoting%20into%20IaaS%20VM%20resources%2C%20especially%20when%20you%20have%20a%20locked%20down%20configuration.%20This%20is%20because%20each%20time%20you%20start%20a%20new%20CloudShell%20session%2C%20a%20container%20is%20spun%20up%20to%20host%20that%20session.%20This%20container%20is%20assigned%20a%20new%20private%20and%20public%20IP%20address.%20In%20this%20article%20you'll%20learn%20how%20to%20figure%20it%20out.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1085251%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1096063%22%20slang%3D%22en-US%22%3ERe%3A%20Determining%20the%20public%20IP%20address%20of%20your%20CloudShell%20session%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1096063%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20for%20the%20Great%20Cloud%20Tip%20of%20the%20Day%26nbsp%3B%3CIMG%20class%3D%22lia-deferred-image%20lia-image-emoji%22%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Fhtml%2Fimages%2Femoticons%2Fcool_40x40.gif%22%20alt%3D%22%3Acool%3A%22%20title%3D%22%3Acool%3A%22%20%2F%3E%20Just%20Shared%20it%20on%20Social%20Media%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

CloudShell is a great tool for performing command line work against resources in Azure. One of the challenges around using CloudShell to remotely SSH or use PowerShell Remoting into IaaS VM resources, especially when you have a locked down configuration. This is because each time you start a new CloudShell session, a container is spun up to host that session. This container is assigned a new private and public IP address.

 

If you are requesting a Just in Time session to a VM, you need to know the IP address that you are going to grant access to. The connection will use the CloudShell session’s public IP address, which means you need to know that.

 

If you’ve played around with CloudShell, you know that you can determine the local IP address of the container that hosts your cloudshell session using ifconfig -a as shown in the exhibit.

 

clipboard_image_0.png

Unfortunately this doesn’t help when it comes to determining the remote IP address. Luckily you can determine the public IP address assigned to the CloudShell session using the following command as shown in the exhibit:

 

 

curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'

 

 

clipboard_image_1.png

Once you have this public IP address, you can use it when configuring your JiT session, or when creating a temporary NSG rule. This allows you to have remote access to your IaaS VM from CloudShell without creating a rule that allows remote access to every public IP address that is available to Azure hosts.

1 Comment

Thanks for the Great Cloud Tip of the Day :cool: Just Shared it on Social Media