PHP: ssh2_connect: cant connect to localhost or machine remotely - php

For the sake of my explanation, keep the following im mind.
Machine 1 Internal = 127.0.0.1
Machine 1 External = 192.0.0.1
Machine 2 Internal = 127.0.0.2
Machime 2 External = 192.0.0.2
Client External = 10.0.0.1
So, I will try to connect to the internal IP of Machine #1, while on Machine #1:
$server = "127.0.0.1";
$conn = ssh2_connect($server, 22);
Results in [/var/log/httpd/error_log]:
[:error] [client 10.0.0.1:0000] PHP Warning: ssh2_connect(): Unable to connect to 127.0.0.1 on port 22 in /var/www/html/file.php on line 8
[:error] [client 10.0.0.1:0000] PHP Warning: ssh2_connect(): Unable to connect to 127.0.0.1 in /var/www/html/file.php on line 8
Changing the IP from internal to external yielded the same error.
Now, I will try to connect to the external IP of machine #1 while the PHP file is ran off of Machine #2's webserver:
$server = "192.0.0.1"
$conn = ssh2_connect($server);
Results in [/var/log/httpd/error_log]:
[:error] [client 10.0.0.1:0000] PHP Warning: ssh2_connect(): Unable to connect to 192.0.0.1 on port 22 in /var/www/html/file.php on line 8
[:error] [client 10.0.0.1:0000] PHP Warning: ssh2_connect(): Unable to connect to 192.0.0.1 in /var/www/html/file.php on line 8
All of this is the case, but oddly enough, if I run the exact code through the php -a interpreter, and proceed to authenticate and run a command, all works flawlessly.
What is the issue??

I was able to resolve this by using setenforce 0.
Honestly the most puzzling issue I've had while programming. Thanks for the help!

Related

Access Telegram-CLI using php

I want to access the Telegram-CLI using PHP.
I'm compiled Telegram-CLI and loged in to my account, and its works like a charm.
I installed LAMP ([in Linux], Apache, MySQL, PHP) and i tested them works.
I even installed these [following] PHP packages one-by-one using "Composer" and tested the examples but i couldnt make them run...
Also it seems their forum are abandoned to get my questions answer.
php-client for telegram-cli
A wrapper for Telegram-CLI
PHP Wrapper and Drupal module using Telegram CLI
Could somebody tell me how to make one of them work in simple way.
All steps of building Telegram-cli, loging in for first time and run it as deamon has beed completed.
For Example:
This project has been installed on php project root dir using "Composer".
Example.php file has been moved to web server root directory.
But also unning it cause a 500 Internal server error.
The error line is:
$telegram = new \Zyberspace\Telegram\Cli\Client('unix:///tmp/tg.sck');
notices:
The file has been checked and is already there.
And the telegram-cli is running as a daemon on root user.
I added a telegramd group and telegramd user assigned to that group.
I detacted that php commands running under apache user account.
I changed the apache user group to telegramd.
But again nothing...
So, Please help me
Edit:
I changed the httpd.conf user and group parameters to run at the same (telegramd) account
User telegramd
Group telegramd
And i have restarted the apache and checked the username by
exec('whoami');
The Apache is running under "telegramd" user account.
But nothing again..
Edit 2:
error_log file:
[Wed Feb 10 11:02:04.251133 2016] [:error] [pid 1172] [client 10.0.1.24:49168] PHP Warning: stream_socket_client(): unable to connect to unix:///tmp/tg.sck (No such file or directory) in /var/www/html/vendor/zyberspace/telegram-cli-client/lib/Zyberspace/Telegram/Cli/RawClient.php on line 48
[Wed Feb 10 11:02:04.251332 2016] [:error] [pid 1172] [client 10.0.1.24:49168] PHP Fatal error: Uncaught exception 'Zyberspace\Telegram\Cli\ClientException' with message 'Could not connect to socket "unix:///tmp/tg.sck"' in /var/www/html/vendor/zyberspace/telegram-cli-client/lib/Zyberspace/Telegram/Cli/RawClient.php:51\nStack trace:\n#0 /var/www/html/example.php(10): Zyberspace\Telegram\Cli\RawClient->__construct('unix:///tmp/tg....')\n#1 {main}\n thrown in /var/www/html/vendor/zyberspace/telegram-cli-client/lib/Zyberspace/Telegram/Cli/RawClient.php on line 51

Accidentally turn on SSL / HTTPS for phpmyadmin

I'm running Ubuntu 14.04.2 LTS, Apache 2.4.7, mysql 14.14, phpinfo.php
I was trying to reconfigure phpMyAdmin and I'm no longer sure what I actually did, because now all attempts to access the page result in a redirect to https, which doesn't work because my Apache server isn't configured to run SSL. I go to http://MYDOMAIN/phpmyadmin and it turns it into https://MYDOMAIN/phpmyadmin/?collation_connection=utf8_general_ci&SID which just has an SSL connection error.
I've tried uninstalling and reinstalling phpMyAdmin several times with no success.
If I go to http://MYDOMAIN/phpmyadmin/setup I get a blank screen but this line shows up in my weblogs:
[Tue Mar 24 05:09:10.518308 2015] [:error] [pid 8888] [client 50.161.45.55:49637] PHP Fatal error: Call to undefined function PMA_generate_common_url() in /usr/share/phpmyadmin/libraries/common.inc.php on line 352
I've tried creating and uncreating /usr/share/phpmyadmin/config/config.inc.php but it seems to have no effect.
Any ideas what I might have done and how I can revert back? mysql is still running fine and I'd rather not have to reinstall that.
Find phpmydmin's config.inc.php and change the line as follows:
$cfg['ForceSSL'] = false;

how can I know what is the necessary permission for my new codeigniter project?

I just installed apache2 and php5 on my ubuntu computer, Ive done it before on debian but now I have a weird error.
when I try to reach a page with my framework in CodeIgniter I get this error
[error] [client 127.0.0.1] PHP Warning: require_once(/var/www/project/system/core/CodeIgniter.php): failed to open stream: Permission denied in /var/www/project/index.php on line 202, referer: localhost/
[error] [client 127.0.0.1] PHP Fatal error: require_once(): Failed opening required '/var/www/project/system/core/CodeIgniter.php' (include_path='.:/usr/share/php5-common') in /var/www/project/index.php on line 202, referer: localhost/
before that I have an error of not found on my include_path, so , I changed it on my php.ini and i changed it to :/usr/share/php5-common
Still... I have NO idea what is the error...
I changed permissions on my /var/www folder and its like user:user
on the line of index.php I have this:
require_once BASEPATH.'core/CodeIgniter.php';
Most probably your $config['base_url'] is wrong.
Make sure its properly identifies the localhost or IP you are using to access localhost.
I mean if you are accessing local server or remote server using http://[ipaddress] then you have to define baseurl like that only.
in your case may be **$config['base_url'] = http://127.0.0.1/codeigniter_project_name**
Similarly that applies to database config also.

Ubuntu 11.10 PHP don't proceed

i've just setup a LAMP development environment on my laptop, all works fine except for php. Apache don't process PHP code embeded inside pages, and display no error. All php package seems to be correctly installed.
Testing a simple: <?php phpinfo(); ?>, give a blank page
error log give:
[Fri Mar 02 20:30:13 2012] [error] [client 127.0.0.1] PHP Fatal error: Unknown: Failed opening required '/home/lib/utils/setDocumentRoot.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
I finally solve my problem, it was due to a fix i've set in my virtualHost config (who was calling a missing file: setDocumentRoot.php), i've disabled that script and all works great.

Investigating mssql_connect problems in PHP

Today, I restarted my CentOS server and after that my PHP application started to fail in accessing our MsSQL server.
[Sun Mar 13 23:44:31 2011] [error] [client 88.154.*.*]
PHP Warning: mssql_connect()
[<a href='function.mssql-connect'>function.mssql-connect</a>]: Unable to connect to server: 85.*.*.109
MsSQL server uses port 1433.
I'm able to get a connection when I try telnet ip 1433 to MsSQL server.
Username and password combination is correct, I'm able to login from another machine.
Nothing has been changed in security settings of MsSQL server.
How can I see what's wrong?
did you double check and make sure that ALL of sql server's services have started?

Categories