2

I need to install software on Azure VM with Ubuntu image. One way of manually doing it is ssh into the terminal using putty or other command-line tool and executing the installation bash command. Another way of doing it was by automating this by creating a bash script and calling it from Azure automation. But I unable to find a way to call the bash script from the azure automation runbooks. Kindly let me know if this is possible.

I am able to call powershell scripts because Azure Automation supports powershell by default.

I tried using the command New-SshSession and using Invoke-SshCommand to run my command but I get the below error while trying to connect to a session.

Also, what are the prerequisites for using New-SshSession (see below)?

New-SshSession -ComputerName 'ComputerName' -Username 'UserName'

Unable to create SSH client object: Exception calling ".ctor" with "4" argument(s): "Could not load type 'System.Security.Cryptography.HMACRIPEMD160' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral,

Are there any prerequisites before I should start using New-SshSession? Do I need to install any .Net library on my linux machine?

roccmol09
  • 33
  • 1
  • 7

1 Answers1

0

Welcome to Stack Overflow!!

If the requirement was for Windows VM then it would have been easy by leveraging Invoke-AzVmRunCommand cmdlet but as requirement is for Linux VM so looks like the comment (with sample script) provided by Azure Automation team content author in this GitHub helps you to accomplish your requirement of executing bash commands on Azure Linux VM using azure automation.

Hope this helps!!

KrishnaG
  • 3,340
  • 2
  • 6
  • 16
  • Thanks! I did come across this issue. It might solve the problem by using REST API endpoint. But in all microsoft documents, it is mentioned that this requirement can be achieved using Hybrid Worker Runbook but nowhere a solution/documentation is provided to support this claim. Quite strange! – roccmol09 Aug 19 '19 at 11:01
  • Just an update... this is also possible using custom script extension for Linux VM. New-SSHSession is unsupported for Linux VM. – roccmol09 Aug 22 '19 at 08:22
  • @KrishnaG-MSFT can this cmdlet be used to upload/transfer files to the VM? – Garbem Mar 02 '21 at 09:52