LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-18-2007, 01:00 AM   #1
hepburnenthorpe
Member
 
Registered: Jun 2006
Location: Sydney
Distribution: Gentoo + Debian
Posts: 132

Rep: Reputation: 15
ssh scripting ?


Little bit stuck here with how I should go about this. I have 3 machines, firewall, utilserv and my main machine (oblivion) which I want to run this script from.

Heres the deal. I have just moved house and have had to go back to a dialup connection. Ive rebuilt my firewall scripts to masquerade and share my dialup. Thing is, because its not always online I need to be able to script the connection from my main machine.

I'll post what I have to see if it makes things clearer.

Code:
#!/bin/bash

case "${1}" in 
    start)
        ssh firewall sudo wvdial
        ssh firewall sudo /usr/sbin/firewall.sh
        ssh firewall sudo /etc/init.d/ntp-client start
        ssh utilserv sudo /etc/init.d/ntp-client start
        sudo /etc/init.d/ntp-client start
    ;; 

    stop)
        ssh firewall sudo kill $(pidof wvdial)
        ssh firewall sudo kill $(pidof pppd)
    ;; 
esac

exit 0
As you can see. From my main machine (running this script) Id'e like to ssh to the firewall, dialup a connection, start the firewall.sh (iptables) script then sync my clocks on all machines.

The stop functionality should disconnect the dialup.

This script partly works. I get the connection, the firewall kicks in and I can use the net from any machine, but, it never gives me my prompt back. It seems to stop after starting the firewall as there is no message about ntp-client starting.

Then, when I go to stop the connection I just get the Uage for kill displayed twice and my modem will not hang up. I have to login to the firewall and kill the process manually.

Am I going abou this all wrong or does anyone have a better solution?

Eventually Id'e like to be able to make connect and disconnect available as fluxbox keyboard shortcuts to make it easy for my girlfriend to get connected. I never had to worry about it before because we had ADSL and where always ON.

Any ideas welcomed. Thanks.
 
Old 04-19-2007, 11:14 AM   #2
ramram29
Member
 
Registered: Jul 2003
Location: Miami, Florida, USA
Distribution: Debian
Posts: 848
Blog Entries: 1

Rep: Reputation: 47
You may need to open port 22 ssh in your firewall configuration.

Use 'killall wvdial' instead.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
vncviewer with ssh scripting question eksit Linux - General 2 10-10-2006 06:11 PM
scripting & ssh zovres Linux - General 2 10-01-2004 11:14 AM
Bash, SSH and scripting. Namuna Linux - Newbie 2 06-08-2004 02:01 PM
Bash scripting... ssh? TheIrish Programming 4 11-27-2003 08:37 AM
SSH and scripting JeRrYmAn Linux - Newbie 4 11-25-2003 12:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration