OoO
OoO

Reputation: 63

How to connect Azure Linux VM via Azure DevOps pipelines using PowerShell

How to connect Linux vm using PowerShell script via pipeline. My SSH (.pem) file is stored in Library in secure file folder.

This PowerShell script I'm trying to pass the AZ CLI. [1]: https://i.sstatic.net/obn2Y.png [2]: https://i.sstatic.net/TrOQh.png

Upvotes: 2

Views: 472

Answers (1)

Bowman Zhu
Bowman Zhu

Reputation: 7251

How to connect Azure Linux VM via Azure DevOps pipelines using PowerShell

The answer is yes, but only support HTTP/HTTPS.

I notice you mentioned .pem file, I think you want to use powershell to connect to your linux VM via .pem file? If yes, then the answer to your question is NO.

If you are trying to use this command:

ssh -i <private key file> <user name of VM>@<VM IP address>

The pipeline will refuse to allocate Pseudo-terminal.


As you know, even you connect to linux VM via powershell, you still run bash after connect to target linux VM.

So there is another way to achieve:

Using SSH Deployment task to connect to target Azure liunx VM:

enter image description here

This is my YAML definition:

trigger:
- none

pool: VMAS

steps:
- task: SSH@0
  inputs:
    sshEndpoint: 'SSH_To_Remote_VM'
    runOptions: 'inline'
    inline: 'ls'
    readyTimeout: '20000'

And my VM's NetWork setting:

enter image description here

Upvotes: 2

Related Questions