Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP and SSH

Options
  • 11-01-2008 5: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