JS>> kiev>> 返回
项目作者: polatengin

项目描述 :
SSH Configuration Helper PowerShell script
高级语言: PowerShell
项目地址: git://github.com/polatengin/kiev.git
创建时间: 2019-07-24T20:57:15Z
项目社区:https://github.com/polatengin/kiev

开源协议:MIT License

下载


SSH Configuration Helper

In projects, we usually need to open SSH connections to remote systems.

For example, we can open an SSH connection to a remote machine from within the Visual Studio Code (you need to have Remote Development extension pack) and develop the project inside of the remote machine.

This scenario allows us to have a thin machine, but still, develop the project with a much more powerful machine with lots of RAM, CPU and even GPU resources on Azure.

But to do that, we need to edit SSH Configuration file

We can find SSH Configuration file in ~/.ssh/config or C:\Users\{USER}\.ssh\config path

Configuration Helper

You can use Configuration Helper PowerShell Script to make it easier to edit SSH Configuration file

Menu

Reference: ssh_config.ps1#L40

You can choose 1 of the following Menu Items

SSH Configuration Helper Menu

Login to Azure

Reference: ssh_config.ps1#L77

You can login to Azure Portal via Azure CLI to access to the VMs running on Azure.

It’s checking if the user is already logged-in to the Azure Portal, if not, it launches a new browser page to login to the Azure Portal.

If only 1 subscription is available for the user, it selects that subscription, if there is more than 1 subscription, it asks the user to choose one of them, and, it sets that subscription as Default.

So, all the upcoming commands will be executed on selected subscription, such as, getting the list of VMs, etc.

List VM Machines

Reference: ssh_config.ps1#L108

It’s getting all the VMs on Azure Subscription and list them with Names and Power States

Start VM Machine(s)

Reference: ssh_config.ps1#L120

It’s getting all the VMs on Azure Subscription, list them with checkboxes, selected VMs will be started

Stop VM Machine(s)

Reference: ssh_config.ps1#L133

It’s getting all the VMs on Azure Subscription, list them with checkboxes, selected VMs will be stopped

Clean SSH Configuration File

Reference: ssh_config.ps1#L146

It parse the SSH Configuration file and creates a ConfigItem array.

Lists ConfigItem array with checkboxes, selected ConfigItems will be preserved, others will be removed from the SSH Configuration file

Add SSH Config for Azure VMs

Reference: ssh_config.ps1#L232

It gets all the VMs on the Azure Subscription, lists them with checkboxes, for the selected VMs a new ConfigItem element will be created.

All the ConfigItems will be appended to the SSH Configuration file

Help

Reference: ssh_config.ps1#L281

SSH Configuration Helper

References

Write-Menu function for PowerShell (created by QuietusPlus) helped a-lot during the development of this script.