sambo
sambo

Reputation: 63

PHP reuse SSH connection in another page

Just wondering, is there anyway to reuse a ssh connection in abother php script page. like, I open a connection on page A, and I finished ahtorization, but I want to process user command in another script page B, is ther any way to run the command avoid to estanblish another connection?

Upvotes: 1

Views: 444

Answers (4)

salva
salva

Reputation: 10242

Yes, it can be done if you use OpenSSH to connect to the remote server and use the connection multiplexing feature.

Read the ssh manual pages for the details, specially the ControlMaster entry in ssh_config(5).

Upvotes: 0

user530167
user530167

Reputation:

@code_burgar: what about mysql_pconnect()?

To the OP: what about replacing all instances of fsockopen() with pfsockopen() in phpseclib, a pure PHP SSH implementation

Upvotes: 2

maxgalbu
maxgalbu

Reputation: 438

No, php closes all the resource handles when it's finished. Even if it didn't, you can't save the state of a resource.

Upvotes: 1

code_burgar
code_burgar

Reputation: 12323

Won't work for the same reasons that a MySQL connection opened in one php script wont work in a second one.

Upvotes: 1

Related Questions