Issue
I'm looking to connect to a server using ssh. I read in the documentation that I also need to specify the public key.
ssh2_auth_pubkey_file ( resource $session , string $username , string $pubkeyfile , string $privkeyfile [, string $passphrase ] ) : bool
Is it possible to ommit the pub key?
Also I would like to pass the value of the private file instead of the path to the file
Solution
SSH is based on public key cryptography approach. In such a system, any person can encrypt a message using the receiver's public key, but that encrypted message can only be decrypted with the receiver's private key.
Therefore you need to use two keys for the communication here: public key for the server to be able to encrypt returned data and at the same time you must habe your private key so you can decrypt what server encrypted. And you must it your private key private otherwise anyone would be able to decrypt the data, making whole effort futile.
Answered By - Marcin Orlowski