Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In-so-far as the permissions go... if phpseclib is running as one user and the key was created by another use then that'd be why phpseclib can't read it with owner read only on they keyfile. To work around this you could do a number of things. #3

Open
Mohzxz opened this issue Mar 18, 2024 · 0 comments

Comments

@Mohzxz
Copy link

Mohzxz commented Mar 18, 2024

          In-so-far as the permissions go...  if phpseclib is running as one user and the key was created by another use then that'd be why phpseclib can't read it with owner read only on they keyfile. To work around this you could do a number of things.
  1. You could copy / paste the keyfile's contents into the PHP file as a string and then pass the string to to PublicKeyLoader.
  2. You could make PHP run as the same user as the key is owned by
  3. You could put the key and the user that PHP is running as into the same group and then enable group read vs just public read.
  4. You could use ssh-agent to get store and retrieve the key

As for phpseclib not being able to read a PuTTY key... it supports both of these styles of keys:

PuTTY-User-Key-File-2: ssh-rsa
Encryption: none
Comment: phpseclib-generated-key
Public-Lines: 2
AAAAB3NzaC1yc2EAAAADAQABAAAAQQCo9+BpMRYQ/dL3DS2CyJxRF+j6ctbT3/Qp
84+KeFhnii7NT7fELilKUSnxS30WAvQCCo2yU1orfgqr41mM70MB
Private-Lines: 4
AAAAQCCS4sQctqqRaEuA0pqBJqN6hstLes9PQCCbR/uTnkVdW3vjeHA2CSn3xsw2
vPL0BDWYkZtBkaumvhzxkDHdpE0AAAAhAKMSvzIBnni7ot/OSie2TmJLY4SwTQAe
vXysE2RbFDYdAAAAIQEJQRpFCcydunv2bENcN/oBTRw39E8GNv2pIcNxZkcbNQAA
ACATrP+Toj4KE3Usu23BfSBqUhPGYBis4GEFWXjfe2BNNA==
Private-MAC: bc712a70870b4b8ddf120530f02b9068e782a21a
PuTTY-User-Key-File-3: ssh-rsa
Encryption: none
Comment: phpseclib-generated-key
Public-Lines: 2
AAAAB3NzaC1yc2EAAAADAQABAAAAQQCo9+BpMRYQ/dL3DS2CyJxRF+j6ctbT3/Qp
84+KeFhnii7NT7fELilKUSnxS30WAvQCCo2yU1orfgqr41mM70MB
Private-Lines: 4
AAAAQCCS4sQctqqRaEuA0pqBJqN6hstLes9PQCCbR/uTnkVdW3vjeHA2CSn3xsw2
vPL0BDWYkZtBkaumvhzxkDHdpE0AAAAhAKMSvzIBnni7ot/OSie2TmJLY4SwTQAe
vXysE2RbFDYdAAAAIQEJQRpFCcydunv2bENcN/oBTRw39E8GNv2pIcNxZkcbNQAA
ACATrP+Toj4KE3Usu23BfSBqUhPGYBis4GEFWXjfe2BNNA==
Private-MAC: 53ba974a4a5f8ac69eb526fd0556fe1a5ccf654216d261af04aca910967b2204

If you have a key that phpseclib can't read you'll need to share it with me so that I might reproduce the problem. If you don't want the world t see the key yo ucan email it to terrafrost@php.net.

I don't think a private key should ever be set to be read publicly, so I'm not sure what's going on. Is it the intention of phpseclib to only work with a publicly readable private key?

There's nothing phpseclib can do about this. If the user phpseclib is created as didn't create the key and you have it so that only the owner of the key can read it then there's not much phpseclib can do about that. And that's not a phpseclib thing - that's a Linux thing.

Originally posted by @terrafrost in phpseclib/phpseclib#1951 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant