ESXi 검색 결과

1개 발견
  1. 미리보기
    2015.06.16 - mr.november11

    VMWare ESXi 에 php로 ssh 접속 시 ssh2_auth_password함수에서 Exception이 발생하는 경우


VMWare ESXi 에 php로 ssh 접속 시 ssh2_auth_password함수에서 Exception이 발생하는 경우


/etc/ssh/sshd_config 파일에 PasswordAuthentication 항목을 yes로 설정한다.


Cannot SSH to VMWare ESXi server using PHP but can connect using Linux Terminal

Tagphp linux ssh vmware esxi Author: hellocoral Date: 2014-04-20
  • Asterisk
  •  
  • Connect Using
  •  
  • Develop Skill
  •  
  • Disclosures
  •  
  • Echos
  •  
  • Esxi
  •  
  • How to develop

When I SSH to VMWare ESXi server, there is no problem.

sshpass -p 'my_password' ssh root@xxx.xxx.xxx.xxx 

But when I try connecting via PHP script, an error appears: PHP Warning: ssh2_auth_password(): Authentication failed for root using password. I don't see "Authentication Successful!" nor "Authentication Failed" as defined in my PHP script. I tried SSHing to a different server (non-ESXi), thePHP script works without any problems.

Here is my PHP script:

<?php
$conn = ssh2_connect('xxx.xxx.xxx.xxx', 22);
if(ssh2_auth_password ( $conn, 'root', 'my_password')) {
    echo "Authentication Successful!\n";
} else {
    die("Authentication Failed...");
}
?>

I don't know if there is something wrong with my code, PHP SSH library, or something with ESXi server? Please help...

Best Answer

This error could be because PHP doesn't have the privilege to connect to ESXi as root user. If that's the case, try logging into the ESXi server and execute the following commands to see if PasswordAuthentication is set to no.

cd /etc/ssh
cat d| grep PasswordAuthentication

If it is no, set it to yes. If you don't have any text editors installed (which was my case), you can do the following:

sed -i "s/PasswordAuthentication\ no/PasswordAuthentication\ yes/g" ./sshd_config

Restart the services.

/sbin/services.sh restart

Now see if the PHP script connects to the server.


다른 카테고리의 글 목록

ESXi 카테고리의 포스트를 톺아봅니다