我如何在PHP的SSH2函数使用PEM文件函数、文件、如何在、PHP

2023-09-11 09:05:18 作者:莫待无花空折枝

我需要通过PHP的SSH2功能连接到某些亚马逊EC2实例来获得一些信息,并在我的后台显示出来。

I need to connect to some Amazon EC2 instances through php's ssh2 functions to get some info and display it on my backoffice.

有没有办法在SSH2功能做同样的我通过命令行SSH?

Is there a way in ssh2 functions to do the same I do when connecting through the command line ssh?

ssh -i path_to_file/key.pem host01-ec2

感谢

推荐答案

您可以使用 openssl_pkey_get_public 提取酒吧/私钥,然后用的 ssh2_auth_pubkey_file 授权。

You can use openssl_pkey_get_public to extract the pub/private keys, and then use ssh2_auth_pubkey_file to authorize.