Tuesday, April 21, 2015

Using PowerShell to Automate Avamar Tasks with SSH

I wanted to give our operations group the ability to execute various scripts or commands on the Avamar utility node without giving them direct SSH access. This can be accomplished using key based authentication, Plink, and powershell.


  1. Download Plink and PuTTYgen from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
  2. Use PuTTYgen to create your key pair. Save both the public and private key
  3. Log onto the Avamar utility node and add the contents of the private key to the authorized_keys file in the ~user/.ssh directory.
  4. Save the private key and Plink on the windows computer that you will be running the powershell scripts on. Protect your private key. Anyone that gains access to the file will have access to the utility node. 
  5. Create your PowerShell script. In this example you need to set the variables for where the key and Plink reside, the full path to the private key, and the command you want to execute.
    • $plinkfolder="C:\Program Files (x86)\PuTTY"
      $privateKey="C:\Program Files (x86)\PuTTY\avamar_vmware_script_priv.ppk"
      $avamarunode="user@ahavmrun.ent.lolcentral.com"
      $Command="/usr/bin/java -jar /usr/local/avamar/bin/proxycp.jar --selectalldatastore"
      cd $plinkfolder
      ./plink.exe $avamarunode -ssh -i $privatekey $Command
Now anyone you give access to execute that script will be running  "/usr/bin/java -jar /usr/local/avamar/bin/proxycp.jar --selectalldatastore" on the utility node. Keep in mind that if they know what they are doing, can edit the file, or access the key, they can do whatever they want on the utility node.

No comments:

Post a Comment