Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

PHP and SSH

  • 11-01-2008 05:02PM
    #1
    Closed Accounts Posts: 25,848 ✭✭✭✭


    Hi guys

    I am trying to set up a SSH tunnel with port mapping to a database server so I can connect using Postgresql PHP command pg_connect to tunnel through the SSH connection to the database

    Basically something like this
    $ssh_com = "ssh -L 5432:db_server:5432 wicknight@db_server &";
    exec ($ssh_com);
    
    pg_connect ("host=localhost port=5432 user=wicknight etc etc");
    

    I have a pub/private key set up under the apache user so the SSH command doesn't need a password The ssh command runs fine from the command line under the apache user and I can run just a normal ssh command to like read a directory or something just fine.

    it seems to just run and stop as if finsihed when run from PHP.

    Anyone know how to get this to work?

    Or is this a really dumb way of doing what I want (basically the database server is in a DMZ that only allows ssh but I still want to be able to connect to the DB)


Advertisement