且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

php运行git得到"ssh许可被拒绝";

更新时间:2022-05-15 08:28:23

这里有很多变量...但是我正在使用的远程cgi脚本面临着几乎完全相同的行为.

A lot of variables here... but I faced pretty much exact same behavior with a remote cgi script I was working on.

就我而言,该问题与CentOS上的SELinux有关.

In my case the issue was related to SELinux on CentOS.

user@remoteserver:~$ getsebool -a | grep httpd

显示:

...
httpd_can_network_connect --> off
...

测试可能的修复程序(sudo或以root身份运行):

Test Possible Fix(sudo or run as root):

user@remoteserver:~$ setsebool httpd_can_network_connect=1
//...then initiate your serverside script remotely

永久修复(如果已证明有效):

Permanent Fix(if above has proven effective):

user@remoteserver:~$ setsebool -P httpd_can_network_connect=1

-P选项可确保在将来重新引导时将主题SELinux布尔值设置为默认值. 看: man getseboolman setsebool

-P option ensures subject SELinux boolean value is set to specified value as default on future reboots. See: man getsebool and man setsebool