Sibeesh Passion

Top Menu

  • Home
  • Search
  • About
  • Privacy Policy

Main Menu

  • Articles
    • Azure
    • .NET
    • IoT
    • JavaScript
    • Career Advice
    • Interview
    • Angular
    • Node JS
    • JQuery
    • Knockout JS
    • Jasmine Framework
    • SQL
    • MongoDB
    • MySQL
    • WordPress
  • Contributions
    • Medium
    • GitHub
    • Stack Overflow
    • Unsplash
    • ASP.NET Forum
    • C# Corner
    • Code Project
    • DZone
    • MSDN
  • Social Media
    • LinkedIn
    • Facebook
    • Instagram
    • Twitter
  • YouTube
    • Sibeesh Venu
    • Sibeesh Passion
  • Awards
  • Home
  • Search
  • About
  • Privacy Policy

logo

Sibeesh Passion

  • Articles
    • Azure
    • .NET
    • IoT
    • JavaScript
    • Career Advice
    • Interview
    • Angular
    • Node JS
    • JQuery
    • Knockout JS
    • Jasmine Framework
    • SQL
    • MongoDB
    • MySQL
    • WordPress
  • Contributions
    • Medium
    • GitHub
    • Stack Overflow
    • Unsplash
    • ASP.NET Forum
    • C# Corner
    • Code Project
    • DZone
    • MSDN
  • Social Media
    • LinkedIn
    • Facebook
    • Instagram
    • Twitter
  • YouTube
    • Sibeesh Venu
    • Sibeesh Passion
  • Awards
  • Linux Azure Function Isolated Dot Net 9 YAML Template Deployment

  • Build, Deploy, Configure CI &CD Your Static Website in 5 mins

  • Post Messages to Microsoft Teams Using Python

  • Get Azure Blob Storage Blob Metadata Using PowerShell

  • Deploy .net 6 App to Azure from Azure DevOps using Pipelines

Azure
Home›Azure›SSH Deployment Task in Azure Pipelines

SSH Deployment Task in Azure Pipelines

By SibeeshVenu
April 29, 2019
209
0
Share:

[toc]

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
  • SSH KeyGen

You can either leave the passphrase blank or provide one, if there are keys available in the default location it will ask for the rewrite. Once the key is generated, you can go to the file id_sra pub file which is located at C:\Users\{username}\.ssh folder, and copy the entire content.

Now we can manually SSH into our VM and add our public key to the VMs authorized_keys.

ssh root@IP

Once you are logged in to the VM, you can add the newly generated public key to the authorized_keys.

cd .ssh/
touch authorized_keys

You can add the content by running the preceding command.

echo "<RSA Public Key>" > authorized_keys

Please paste your public key inside the quotation (“”). As we already have our Private and Public key with us, now we can go ahead and create our SSH service connection.

Set Up the SSH Service Connection

First thing first, let’s create a SSH service connection in our Azure DevOps so that we can use it in our SSH Deployment Task.

Go to your Project Settings in your Azure DevOps project and click on the Service Connections and then click the +New service connection and then select SSH.

Service Connection

In the next dialogue box, you should fill all the details as preceding.

Add SSH Service Connection

Create the Release Pipeline

Wow!. We have created our Service connection successfully, and now it is time to use it. Go to your Azure DevOps project and click on Pipelines and then Releases. Now click on +New button and then +New release pipeline.

In the next dialogue, you should select the template for your pipeline, in this case, I will select “Empty Job”. Now click on the Tasks and then Agent Job. You can verify the Agent Job details, and once it is done, click on the + icon and then add SSH Task after searching with the keyword “SSH”.

Once the task is added, we can go ahead and set up the configuration.

SSH Task Configuration

Please remember to use the SSH service connection you have created. You can give the commands to run inside the VM in the commands section, each lines will be considered as a new command. You can always disable the option “Fail on STDER” if you think it is necessary. In my case I had disabled this feature as my UCS machine was running the some background tasks as part of the “univention-app” commands, some of such tasks were returning some errors, as these errors are not part of my releases, and as it is not any impacts in my deployment. Please remember to enable “Continue on error” in such scenarios.

Here, the adm_secret file is the file which contains the password of my UCS Admin Password. You can do this by running the preceding commands.

touch adm-secret;
echso "your secret" > adm_secret

Once your configuration is done, save your release configuration and create a new release. I hope the release will be successful.

Release Pipeline Result

Conclusion

In this article, we have learned,

  • How to create SSH Service connection in Azure DevOps
  • How to create and configure SSH Task in Azure Pipelines
  • How to generate Private and Public RSA keys

Please let me know what else you had learned from this Article.

Your turn. What do you think?

Thanks a lot for reading. Did I miss anything that you may think which is needed in this article? Could you find this post as useful? Kindly do not forget to share me your feedback.

Kindest Regards
Sibeesh Venu

TagsAzureAzure DevOpsSSHUCSVirtual Machines
Previous Article

Publish Your Angular GitHub Repository as a ...

Next Article

Microsoft MVP 2019 – 2020

0
Shares
  • 0
  • +
  • 0
  • 0
  • 0

SibeeshVenu

I am Sibeesh Venu, an engineer by profession and writer by passion. Microsoft MVP, Author, Speaker, Content Creator, Youtuber, Programmer.

Related articles More from author

  • Back Up And Restore Your Old MySQL Database to New Database
    AzureDatabaseMySQLVirtual Machine

    Back Up your ClearDB and restore in Azure Virtual Machine MySQL

    September 18, 2015
    By SibeeshVenu
  • cdn-overview
    AzureHow to

    Azure Content Delivery Network (CDN) – A Walk Through

    May 28, 2017
    By SibeeshVenu
  • get users from different tenants graph
    Azure

    Get Users From Different Tenants Using Azure AD Application Permission

    February 2, 2021
    By SibeeshVenu
  • Web hosting Account
    Azure

    How to map your domain name to your Azure website

    June 1, 2015
    By SibeeshVenu
  • VM IP configuration
    Azure

    Creating an Azure VM from the VHDX/VHD File

    March 6, 2019
    By SibeeshVenu
  • Microsoft Azure Logo
    Azure

    What Azure Is?

    July 8, 2015
    By SibeeshVenu
0

My book

Asp Net Core and Azure with Raspberry Pi Sibeesh Venu

YouTube

MICROSOFT MVP (2016-2022)

profile for Sibeesh Venu - Microsoft MVP

Recent Posts

  • Linux Azure Function Isolated Dot Net 9 YAML Template Deployment
  • Build, Deploy, Configure CI &CD Your Static Website in 5 mins
  • Easily move data from one COSMOS DB to another
  • .NET 8 New and Efficient Way to Check IP is in Given IP Range
  • Async Client IP safelist for Dot NET
  • Post Messages to Microsoft Teams Using Python
  • Get Azure Blob Storage Blob Metadata Using PowerShell
  • Deploy .net 6 App to Azure from Azure DevOps using Pipelines
  • Integrate Azure App Insights in 1 Minute to .Net6 Application
  • Azure DevOps Service Connection with Multiple Azure Resource Group

Tags

Achievements (35) Angular (14) Angular 5 (7) Angular JS (15) article (10) Article Of The Day (13) Asp.Net (14) Azure (65) Azure DevOps (10) Azure Function (10) Azure IoT (7) C# (17) c-sharp corner (13) Career Advice (11) chart (11) CSharp (7) CSS (7) CSS3 (6) HighChart (10) How To (9) HTML5 (10) HTML5 Chart (11) Interview (6) IoT (11) Javascript (10) JQuery (82) jquery functions (9) JQWidgets (15) JQX Grid (17) Json (7) Microsoft (8) MVC (20) MVP (9) MXChip (7) News (18) Office 365 (7) Products (10) SQL (20) SQL Server (15) Visual Studio (10) Visual Studio 2017 (7) VS2017 (7) Web API (12) Windows 10 (7) Wordpress (9)
  • .NET
  • Achievements
  • ADO.NET
  • Android
  • Angular
  • Arduino
  • Article Of The Day
  • ASP.NET
  • Asp.Net Core
  • Automobile
  • Awards
  • Azure
  • Azure CDN
  • azure devops
  • Blockchain
  • Blog
  • Browser
  • C-Sharp Corner
  • C#
  • Career Advice
  • Code Snippets
  • CodeProject
  • Cognitive Services
  • Cosmos DB
  • CSS
  • CSS3
  • Data Factory
  • Database
  • Docker
  • Drawings
  • Drill Down Chart
  • English
  • Excel Programming
  • Exporting
  • Facebook
  • Fun
  • Gadgets
  • GitHub
  • GoPro
  • High Map
  • HighChart
  • How to
  • HTML
  • HTML5
  • Ignite UI
  • IIS
  • Interview
  • IoT
  • JavaScript
  • JQuery
  • jQuery UI
  • JQWidgets
  • JQX Grid
  • Json
  • Knockout JS
  • Linux
  • Machine Learning
  • Malayalam
  • Malayalam Poems
  • MDX Query
  • Microsoft
  • Microsoft ADOMD
  • Microsoft MVP
  • Microsoft Office
  • Microsoft Technologies
  • Microsoft Windows
  • Microsoft Windows Server
  • Mobile
  • MongoDB
  • Monthly Winners
  • MVC
  • MVC Grid
  • MySQL
  • News
  • Node JS
  • npm
  • Number Conversions
  • October 2015
  • Office 365
  • Office Development
  • One Plus
  • Outlook
  • Page
  • PHP
  • Poems
  • PowerShell
  • Products
  • Q&A
  • Raspberry PI
  • React
  • SEO
  • SharePoint
  • Skype
  • Social Media
  • Software
  • Spire.Doc
  • Spire.PDF
  • Spire.XLS
  • SQL
  • SQL Server
  • SSAS
  • SSMS
  • Storage In HTML5
  • Stories
  • Third Party Software Apps
  • Tips
  • Tools
  • Translator Text
  • Uncategorized
  • Unit Testing
  • UWP
  • VB.Net
  • Videos
  • Virtual Machine
  • Visual Studio
  • Visual Studio 2017
  • Wamp Server
  • Web API
  • Web Platform Installer
  • Webinars
  • WebMatrix
  • Windows 10
  • Windows 7
  • Windows 8.1
  • Wordpress
  • Writing

ABOUT ME

I am Sibeesh Venu, an engineer by profession and writer by passion. Microsoft MVP, Author, Speaker, Content Creator, Youtuber, Programmer. If you would like to know more about me, you can read my story here.

Contact Me

  • info@sibeeshpassion.com

Pages

  • About
  • Search
  • Privacy Policy
  • About
  • Search
  • Privacy Policy
© Copyright Sibeesh Passion 2014-2025. All Rights Reserved.
Go to mobile version