Replies: 4 comments
-
phpseclib v3 supports RSA, DSA, ECDSA and Ed25519 / Ed448. If by RSA2 you mean rsa-sha2-256 and rsa-sha2-512 then you can absolutely create those keys with As for creating an Ed25519 key... quoting https://phpseclib.com/docs/ec#creating-keys you'd do |
Beta Was this translation helpful? Give feedback.
-
@terrafrost thank you for your clarification, yes, I mean rsa-sha2-256 and rsa-sha2-512. Ss there any way that I can know what public key algorithms are accepted by ssh server if I connect to it using phpseclib SSH2 ? |
Beta Was this translation helpful? Give feedback.
-
@terrafrost I'm trying to generate a key with md5 or sha512 hash. But when I use those keys to log in to a SSH server, all of them looks like sha256. $key = RSA::createKey(4096); But in my SSH server, it reads that key as RSA SHA256 as you can see: And If I load the the previously generated private key withHash ('md5' or 'sha512') with RSA::loadFormat('PKCS1', $private); And I print it, it shows that the hash is sha256. Is toString() ignoring the withHash configured parameter? Am I doing something wrong generating those keys? |
Beta Was this translation helpful? Give feedback.
-
I'm just now seeing this :(
$ssh = new SSH2(...);
print_r($ssh->getSupportedHostKeyAlgorithms()); That'll get you a list of server signature algorithms that the server supports, which may or may not be the same list of algorithms that the server accepts for authentication.
Altho phpseclib RSA objects let you specify a hash most string serializations do not contain that info. For phpseclib the whole And by most I mean... for RSA there are different PKCS8 style key types for rsaEncryption and id-RSASSA-PSS. The hash isn't stored but the padding type is. But outside of that no other info about how the key should be used is really stored (altho a full blown X.509 key could contain that info)
Correct. The string formats are not formats I made up. The hash is not stored in the string format so when you load it back up from a string it's just using the default hash algorithms. |
Beta Was this translation helpful? Give feedback.
-
Hello,
Is there any way that I can get what public keys are supported in a SSH server using phpseclib?
My idea is to connect to the SSH server using password authentication using phpseclib, and then fetch the supported public keys format, so I can generate a key that is being supported for that server.
And another question is, how can I generate RSA2 and ed25519 public keys for SSH authentication with phpseclib?
I know can I create ssh-rsa keys wtih RSA::createKey() method, but not RSA2 or ed25519.
Thanks for your help!
Beta Was this translation helpful? Give feedback.
All reactions