Skip to main content

Generate SSH config file from Azure ARM VM inventry in subscription

Project description

Generate SSH config file from Azure ARM VM inventry in subscription

Introduction

azuresshconfig is a simple script that collects Azure ARM Virtual Machine(VM) inventry in subscription and generate a SSH config entries to be appended to $HOME/.ssh/config (the file is newly created if no exist). This is like an Azure version of ec2ssh or aws-ssh-config that strongly inspired this initiative. This would be very helpful when you manage lots of VMs that have dynamic IP assignment settings and need frequent VM up-and-down operations for them which causes the change of IPs assigned to VMs. In such a case, azuresshconfig will definitly make your SSH life easy.

Installation

pip install azuresshconfig

Configuration

Generate client profile template file by executing the following command.

azuresshconfig --init

Configure the client profile file, in which you add your service principal account info to access your resources in Azure via Azure APIs.

vi $HOME/.azure/azuresshconfig.json

{
    "subscription_id": "<YOUR SUBSCRIPTION ID>",
    "client_id": "<YOUR APPLICATION CLIENT IP>",
    "client_scret": "<YOUR APPLICATION CLIENT SCRET>",
    "tenant_id": "<YOUR TENANT ID>"
}

For those who don’t know how to create service principal, there is a great instruction: Use Azure CLI to create a service principal to access resources. If you have Azure CLI 2.0 command installed on your evironment, you can create your service principal and configure its access to your azure resources with a single command ‘az ad sp create-for-rbac’.

Suppose your app id uri is ‘http://unofficialism.info’ and role you want to give for the app is ‘Reader’, you can create your service principal like this:

az ad sp create-for-rbac -n "http://unofficialism.info" --role reader

You will get an output like this, and with them you can fill out the client profile file:

{
  "appId": "c36x4b4f-bef6-422e-bd3b-65057e7ab065",        # -> client_id in client profile file
  "displayName": "azure-cli-2017-03-30-05-16-59",
  "name": "http://unofficialism.info",
  "password": "32126d32-7453-4053-3353-c420d4ffef2e",     # -> client_scret in client profile file
  "tenant": "72f988bf-86f1-41af-91cb-2d7cd011db47"        # -> tenant_id in client profile file
}

For the detail of service principal role, please refer to Built-in roles for Azure Role-Based Access Control.

Usage

Assuming all required packages are installed and rightly configured, you’re ready to run azuresshconfig

``` azuresshconfig –help

usage: azuresshconfig.py [-h] [–version] [–init] [–profile PROFILE] [–output OUT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

azuresshconfig-0.3.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

azuresshconfig-0.3.0-py2.py3-none-any.whl (39.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file azuresshconfig-0.3.0.tar.gz.

File metadata

File hashes

Hashes for azuresshconfig-0.3.0.tar.gz
Algorithm Hash digest
SHA256 39e4df8ecbabc1751c124a29a7440b06f3a14585d0943cf04163b6a79358d4da
MD5 417f1dc9626e3469f7b292305181f4ba
BLAKE2b-256 f81ceacb81651f25db62c23f73b1e02fde5329b9bb6cdefb0a92dc07ce012742

See more details on using hashes here.

File details

Details for the file azuresshconfig-0.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for azuresshconfig-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 40868e5b3c1d81b30bd144972b5a7e90e9b6285e4b36ff7140d0aeb69404bfee
MD5 9200318c8944c177aa320d2562778808
BLAKE2b-256 3aeef0a55d8c45d796d7ba8244821cdc8635612ee8daafdcc86f59767a728fec

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page