Solved

Creating a script to test a local website

Posted on 2006-07-17
9
245 Views
Last Modified: 2013-12-16
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
Comment
Question by:london_mccourt
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 14

Expert Comment

by:DonConsolio
ID: 17122280
you might want to have a look at "nessus"
0
 
LVL 39

Expert Comment

by:noci
ID: 17122374
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
 

Author Comment

by:london_mccourt
ID: 17122378
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
 

Author Comment

by:london_mccourt
ID: 17122749
I'm kinda looking for a few examples, I've gone through the man pages.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 39

Accepted Solution

by:
noci earned 400 total points
ID: 17124723
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
 
LVL 22

Expert Comment

by:pjedmond
ID: 17124953
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
 
LVL 22

Expert Comment

by:pjedmond
ID: 17202429
..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
 

Author Comment

by:london_mccourt
ID: 17295458
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
 
LVL 39

Expert Comment

by:noci
ID: 17306941
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now