I already wrote a php file that connects locally to the mysql database. Now I want to connect to a remote database via SSH. Currently the connection function for my database in php:
$this->db = new mysqli(_SERVR_URL, _SERVR_USER , _SERVR_PASS, _SERVR_DB); if ($this->db->connect_errno) { echo "Failed to connect to MySQL: (" . $this->db->connect_errno . ") " . $this->db->connect_error; } else{
I only want to change the connection function (see above) so that the rest of the code still works. I have successfully installed phpseclib and am not interested in installing php ssh extensions because they did not work after almost 5 hours of effort. Phpseclib works, and I think that is because when I use it does not die.
However, when I try to start working with the ssh file, it gives a server error:
$ssh = new Net_SSH1(myURL);
As usual, I use SSH on my server with a .pem file. Can I get some recommendations on:
- Why can the current code cause an error?
- If possible.
- How would you write the connection code with the .pem file.
source share