2

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

1
  • In pipeline, unable to use powershell connect linux Azure VM with .pem file, but there is another way, see my answer. :) Commented Nov 21, 2022 at 8:17

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.