[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

Creating a script to test a local website

Hello all,

I have a requirement for a script to test certificate expiry on particular ports on a server.  However the server is located in a DMZ and is accessable only via SSH.  I thought about opening the ports up, but there are roughly about 100 of these servers, the over head is far too much, also the script uses specific SSLEAY and various other perl modules to work.  I'm looking to have a central reporting server that basically periodicaly logs on via SSH, creates a SSH Tunnel, Perl script executes and examines specific ports on the destination server out put is pushed into a file.  I know I can get around the SSH logon stuff with creating certificates on the client and destination servers, but how can I tunnel the ports in a script and keep them open to allow another script  to execute on the client server?

I have the Perl script etc.., I only want to know how the SSH stuff will work

More info if required.

And Thanks to all in advance.
0
london_mccourt
Asked:
london_mccourt
  • 3
  • 3
  • 2
  • +1
1 Solution
 
DonConsolioCommented:
you might want to have a look at "nessus"
0
 
nociSoftware EngineerCommented:
man ssh

will show options like -L & -R You can experiment with that.

If you are looking for a more generic monitor nagios might be usefull for the reporting & monitoring.

0
 
london_mccourtAuthor Commented:
thanks Don, Nessus is a little colossus for me, I like the output I get from this script, I'd rather stick to it.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
london_mccourtAuthor Commented:
I'm kinda looking for a few examples, I've gone through the man pages.
0
 
nociSoftware EngineerCommented:
ssh -L localhost:12345:anotherremotehost:5678 someuser@remotehost -f

I am assuming you have setup private/public keys ...

will open a tunnel from your host to the remotehost and build a tunnel ,
then allow connections on the localsystem to port 127.0.0.1:12345 to have the
remotehost connect to another remotehost port 5678

0
 
pjedmondCommented:
I know you said you were familiar with client and server certificates....but are you doing them properly, and protecting them with a password?

http://www.cvrti.utah.edu/~dustman/no-more-pw-ssh/

You can execute a command on the remote server:

ssh someuser@remotehost command

so if you want to ls a directory and put the data into a file on the local machine:

echo `ssh someuser@remotehost ls -al ` > output.txt

(   (()
(`-' _\
 ''  ''



0
 
pjedmondCommented:
..or alternatively, stick your perl script on the server concerned, and record the output locally:

echo `ssh someuser@serverindmz.com myscript.pl ` > output.txt

(   (()
(`-' _\
 ''  ''
0
 
london_mccourtAuthor Commented:
noci, thanks for your help

Oddly I'm using the below line in my script (cert passwordless connections working great.

$SERVNM = remote host name
$SERVPRT = remote post port

ssh -v -N -L 12345:$SERVNM:$SERVPRT user@$SERVNM -i $HOME/identity-test/id_rsa

I have done a combination of nohup, -f, sh, and traling & to have the tunnel 'spawned' off so that the rest of the script can execute, but the script stops everytime and doesn't continue until I break it.

The tunnel works really well, I can open another console and telnet to the new port no problem.

Any ideas?
0
 
nociSoftware EngineerCommented:
a -n is required to disconnect the stdin from the controlling terminal.

a -f should imply a -n... (open ssh at least).
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now