SSH Deployment Task in Azure Pipelines

Sibeesh Venu
5 min readApr 29, 2019
SSH Task Configuration

Introduction

The word automation means a lot to us, the developers. We hate to do the same work again and again, especially when it comes to some manual work, where we need to do the tasks one by one. With the help of Azure build and release pipelines in Azure DevOps, most of the build and release tasks can be automated. Here in this post, I am going to explain one such task which is SSH Deployment Task. This task is very handy when you want to perform some actions inside your virtual machine by login to the VM via SSH. Let’s jump in to the implementation now then.

Background

In one of my project. I am running a UCS server inside my Azure VM. We can consider the UCS server as a Google Play Store, where we can install and manage the relevant applications. For example, I have created my own application and I am running the same inside the UCS Azure VM. But every time when we have a new changes in the application, we have to update the new application Docker image in the UCS machine by login via SSH, below are some of the operations we do after login to the VM.

  1. univention-app remove {AppName}
  2. docker rmi $(docker ps -q)
  3. univention-app update
  4. univention-app install {AppName}

We had to set up a release pipeline to make our releases easier.

Working with SSH Deployment Task

As I mentioned earlier, this task will enable you to run your specific shell commands in your Virtual Machine. But to do that, we need to do some amazing things.

Create and Upload the Public Key to Azure VM

To set up our SSH Task we need a SSH Service Connection but to configure the connection we need to generate the Public and Private keys, you can use the below command to generate the same.

ssh-keygen -t rsa -b 2048
Generate Keys

You can either leave the passphrase blank or provide one, if there are keys available in the default location it will ask…

--

--

Sibeesh Venu

An engineer by profession and writer by passion. Author at Sibeesh Passion, Microsoft MVP (2016–2022). Software Engineer @ Microsoft