Executing bulk of short commands in queue #1927
-
Hey there, Is there a way to decrease time to login process? In this case, I think there is only one way to fasten the authentication — using ssh-agent or pubkey auth, is it right? @terrafrost Will be glad for your tips ❤️ |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
ssh-agent wouldn't really help that much. All that really does is give you a way to create a signature with a private key and retrieve the public key corresponding to a private key without being able to actually read that private key. The signatures and key exchange and all that jazz still needs to be done. Unless you could make it so that the server doesn't randomly generate numbers there's not a whole lot you can do to cache logins. And if you did make it so that the server served up the same random bytes every time then you'd be introducing security vulnerabilities. I think the best option, in your situation, is going to be to just make it so phpseclib is always running. Do something like this: $ssh = new SSH2(...);
$ssh->login(...);
while (true) {
// query MySQL DB for commands or some such
$commands = [];
foreach ($commands as $command) {
$result = $ssh->exec($command);
// save command output in DB
}
sleep(1);
} |
Beta Was this translation helpful? Give feedback.
ssh-agent wouldn't really help that much. All that really does is give you a way to create a signature with a private key and retrieve the public key corresponding to a private key without being able to actually read that private key. The signatures and key exchange and all that jazz still needs to be done.
Unless you could make it so that the server doesn't randomly generate numbers there's not a whole lot you can do to cache logins. And if you did make it so that the server served up the same random bytes every time then you'd be introducing security vulnerabilities.
I think the best option, in your situation, is going to be to just make it so phpseclib is always running. Do something l…