我如何在PHP的SSH2函数使用PEM文件 [英] How can I use pem files in php's ssh2 functions

查看:729
本文介绍了我如何在PHP的SSH2函数使用PEM文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过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.

这篇关于我如何在PHP的SSH2函数使用PEM文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆