0

I'm trying to setup a programming environment to 14 students using Virtualbox. I have created all the individual machines but now I need to perform remote installs on every machine and I am trying to do it with a ssh script but I'm running in to several problems but my main one is that I can't login as root so I have to use a normal user and perform sudo. Every machine has the user for the student and a super user common to all.

So what I would like is to automate something like this but getting the server list from a file

ssh master@10.1.2.3 "echo 'password' | sudo -S ls /home/; sudo apt-get -y install vim;"

A better example is I need to push an updated hosts config to all the student machines

PS: I know I could have installed the software before I created the machine but the purpose of this exercise is to allow every student to do a full install from a basic debian installation

  • 2
    Please add technical details into exactly what you are doing and the errors you have – Rui F Ribeiro Oct 14 '18 at 16:37
  • 4
    this might be better done with something like Ansible – thrig Oct 14 '18 at 16:43
  • 1
    +1 for Ansible, really designed for this. – xenoid Oct 14 '18 at 17:06
  • 1
    Ansible is not an option. I must be able to do this with ssh and scripts – Armando Correia Oct 14 '18 at 17:16
  • Telling students to type the sudo password in plain text on the command line is a Bad Idea™. Why do you feel it is necessary to use plain shell scripts for this? – l0b0 Oct 15 '18 at 2:58
0

Try the clusterssh package, it provides you with parallel interactive SSH sessions to several hosts.

0

Similar to Ferenc's answer, but another option may be to use GNU parallel.

However:

  1. You definitely want Ansible for this
  2. You definitely want to manage the ssh keys and not send passwords over plain text

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.