Oz N Tiram 5 éve
commit
3abfb4a443
3 módosított fájl, 51 hozzáadás és 0 törlés
  1. 42 0
      README.md
  2. 7 0
      banshible.sh
  3. 2 0
      test.sh

+ 42 - 0
README.md

@@ -0,0 +1,42 @@
+banshible
+---------
+
+You don't need ansible to a set of task on a remote machine.
+Using BASH and SSH is more than enough. But most people tend
+to skip learning the fine details of using SSH, sudo and BASH.
+
+Here is an exterme minimal framework to run a script on a remote server.
+
+
+```
+banshible.sh <remote server> <script-name>
+```
+
+If you need to execute a command with escalated priveleges you can use sudo
+on the remote machine. If you need a password to become root you can echo it.
+Here is an example script that you can run on a remote machine:
+
+```
+$ cat test.sh
+whoami
+echo $PW | sudo -S 2>/dev/null whoami
+```
+
+To run this script on a remote machine:
+
+```
+export PW=<yourVerySecretPassword>
+$ ./banshible.sh <server> test.sh 
+oz123
+root
+```
+
+You can run this script also with specifying the user on the remote machine:
+
+```
+export PW=<VerySecretPasswordOfRemoteUser>
+$ ./banshible.sh <RemoteUser@server> test.sh 
+RemoteUser
+root
+```
+

+ 7 - 0
banshible.sh

@@ -0,0 +1,7 @@
+#!/bin/bash
+ssh $1 bash << EOF
+export PW=$PW
+export SUDO_PROMPT=""
+$(cat $2)
+EOF
+

+ 2 - 0
test.sh

@@ -0,0 +1,2 @@
+whoami
+echo $PW | sudo -S 2>/dev/null whoami