Solved

PROBLEMS CREATING AN SSH TUNNEL in Ruby

Posted on 2013-05-22
2
462 Views
Last Modified: 2013-06-26
Hello,
  I'm writing a series of test that test credit cart transactions and our card service relies on communicating to a sabrix server through an ssh tunnel.
I've created something that works but I have to admit, it doesn't make sense because I'm using a combination of a unix exec call and Net::SSH::Gateway.
In order for the ssh tunnel work with the tests to to work they HAVE to work in conjunction to each other.  I'm ok with it but it seems like 1 out of 10 times, the tests will fail because the ssh tunnel isn't open for some reason.   I've tried about every solution out there but can't seem to get anything else to work.    Here's the code:

  def setup
    super
    @controller = AccountController.new    
    @pid = fork{ exec("ssh -N -L 8888:10.0.1.68:8080 test@test.test.com") } #this has to be open in a thread
    @gateway = Net::SSH::Gateway.new('test.test.com', 'deploy')             #this has to be created as well
    sleep(1) #sleep just a tad to let everything start up
  end

  def test_update_credit_card_info
    #test code here…
  end

Open in new window


And in my teardown method, I'm killing the ssh tunnel like this:

  def teardown
    system("kill -9 #{@pid}") #kill by pid
    @gateway.shutdown!		#kill the Net::SSH::Gateway instance
  end

Open in new window


Any ideas?

Thanks,
Eric
0
Comment
Question by:clemcrock
2 Comments
 
LVL 24

Accepted Solution

by:
fridom earned 500 total points
Comment Utility
0
 

Author Closing Comment

by:clemcrock
Comment Utility
Thanks for all your help.   Love this site!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

I recently rediscovered rails when I needed a holiday project and decided to build a management dashboard for the company where I work.  With it being a project done in my free time, I could focus my time on learning the basics rather than trying to…
In Ruby, Call or invoke a API DLL library is easily via Win32API class, win32-api gem or other gems. For general DLL API call, there are quite a few references, some good tips list below: http://www.rubytips.org/2008/05/13/accessing-windows-api-fro…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

6 Experts available now in Live!

Get 1:1 Help Now