I have a private key file that will be used in the following two use-cases:
SSH -i /path/to/private/keywithin terminal -- Requires 600 permission set
file_get_contents()statement within PHP -- Requires more open permissions set
The file currently has permissions set at
600 to allow usage within SSH via terminal. However because of this I get a permission denied when trying to read the file within PHP.
Please can anyone suggest a viable solution, whilst maintaining good security on the key file, to enable me to use the same key file for both the aforementioned use-cases?
$key = new Crypt_RSA(); $key->loadKey(file_get_contents('private_key.pem')); $ssh = new Net_SSH2('amazon-ec2-ip'); $ssh->login('ubuntu', $key); // HERRO PRIVATE KEY