Executing scripts on a remote machine

These are a few quick tips how to make it real. First what you need: two computers ;), both to have bash and ssh installed and 'authorized_keys' file with public rsa key from the caller machine (only if you want to have communication without password typing)

Now let's do it :

1. Make a simple bash script which we want to execute on a remote machine. You are able to use this one:
#!/bin/bash
echo "Greetings from "$(uname -n)
exit 0
2. Execute this script on a remote machine by running this:
cat simple.sh | ssh user@remote /bin/bash
You should see this output:
Greetings from remote
It's unbelievably simple isn't it ? You send content of the script file through the pipe to a remote machine on which you connect via ssh and where you run the bash in which you execute the script that come from your computer .;) Due to these nice features i do really love unix :)
Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

marigan

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
News
Blogs

No bookmarks in folder