PHP Classes

PHP SSH Connection Session: Run arbitrary length commands in a server with SSH

Recommend this page to a friend!
  Info   View files Documentation   View files View files (11)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2022-10-21 (11 months ago) RSS 2.0 feedStarStarStarStar 79%Total: 395 All time: 6,590 This week: 119Up
Version License PHP version Categories
ssh-session 1.0.9GNU General Publi...5.5Networking, PHP 5, Files and Folders


This package can run arbitrary length commands in a server with SSH.

It can connect to a given ssh server and execute given commands.

If the commands exceed the maximum length, it write the commands to a file and executes it from there using the bash shell.

It can also execute file manipulation functions like uploading and downloading files, creating directories, changing file permissions, renaming files, reading or writing remote file contents, etc..

Innovation Award
PHP Programming Innovation award winner
August 2016

Prize: One downloadable e-book of choice by O'Reilly
SSH is a protocol to communicate with a remote server via a secure connection that allows to execute commands on a remote machine.

However, the length of the commands that can be executed is limited.

This package provides a workaround for this limitation that consists in creating a shell script to execute long commands and execute it using the bash shell.

Manuel Lemos
Picture of Christian Vigh
  Performance   Level  
Name: Christian Vigh <contact>
Classes: 32 packages by
Country: France France
Age: 57
All time rank: 13810 in France France
Week rank: 13 Up1 in France France Up
Innovation award
Innovation award
Nominee: 20x

Winner: 3x



You have to edit the file ; it contains variables that you MUST set to your own configuration needs before running the examples :

  • $host : Host name or IP address of your remote server.
  • port : Port number of the sshd server on your remote system (usually, 22).
  • $user : the user you want to connect to on your remote system.
  • $password : User password (set this variable if you want to run the example.password.php script, which uses password-based authentication)
  • $private\_key\_file, $public\_key\_file : Paths to the files containing your private and public ssh keys (set these variables if you want to run the example.key.php script, which uses ssh key-based authentication)


  • Your remote system MUST be a Unix system for the examples to run as is
  • If you used puttygen to generate your public and private keys, you have to know that the key that is labelled :

    Public key for pasting into OpenSSH authorized_keys file

will not have the correct format for using it as a public key on Unix systems. You will have to go to the Conversions menu and chose the "Export OpenSSH key" option.

  • On your remote Unix system, you must add your public key in the .ssh/authorized_keys file of your remote user
  • And, of course, you must have an sshd server up and running on your remote system !
  Files folder image Files  
File Role Description
Plain text file Authentication.phpclass Class Class source
Plain text file Connection.phpclass Class Class source
Accessible without login Plain text file Conf. Configuration script
Accessible without login Plain text file example.key.php Example Example script
Accessible without login Plain text file example.password.php Example Example script
Plain text file FileSystem.phpclass Class Class source
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file NOTICE Data Auxiliary data
Accessible without login Plain text file Doc. Documentation
Accessible without login Plain text file Doc. Documentation
Plain text file Session.phpclass Class Class source

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:6,590
This week:119Up
User Ratings User Comments (1)
 All time
6 years ago (muabshir)