sharad-github / shellinabox

Automatically exported from code.google.com/p/shellinabox
Other
0 stars 0 forks source link

How to run few commands before startup? #276

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi All,
Iam having a requirement i.e., i dont want to login into the server every time 
i open the following url:

https://<ip>:4200

and would like to run a command dynamically(like ssh <ip> here <ip> will come 
during runtime to me) whenever i open the above url. Is there any way to do 
this  Please help i am very new to this.

My main aim is to ssh to a particular ip(It is a dynamic ip which changes 
regularly)

Thanks in advance

Original issue reported on code.google.com by santoshv...@gmail.com on 13 Jan 2015 at 12:36

GoogleCodeExporter commented 9 years ago
Hi,

You could write your own ssh login wrapper script. In wrapper script you
can ask user for remote server IP address, or you can read it from some 
file etc...

And than you could run shellinaboxd with something like that:

shellinaboxd --service /:$USER:$GROUP:$HOME:/path/to/mysshlogin.sh

Example script "mysshlogin.sh":

------------------

#!/bin/bash

# Read user input
read -p "Please enter remote server address: " remoteserver
echo "Connecting to server ${remoteserver} ..."

# Start ssh connection
ssh root@${remoteserver}

------------------

PS: this script is probably not safe :) you should do some input checking or
something ...

Original comment by luka.kra...@gmail.com on 20 Jan 2015 at 11:30