Download the PHP package sammyjo20/ssh-php without Composer

On this page you can find all versions of the php package sammyjo20/ssh-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ssh-php

# 🤫 _`SSH PHP` !_ ### The ridiculously simple starting point for building PHP SSH apps! 🔥 Screenshot 2024-07-26 at 18 09 49

What the shell?!

I know right? I've just run ssh localhost and I've got a full PHP application running in my terminal?! What! Me too. When I first saw Joe Tannenbaum's Tweet where he showed off his awesome ssh cli.lab.joe.codes I thought to myself, I had to get this working myself. I have a secret project that I'm currently working on but during my research, I managed to adapt his guide for getting charmbracelet/wish running with PHP to work with Docker!

This is project is mainly for building TUIs however it can run any PHP script so you can build cool forms, resumes or anything you desire!

Why Docker?

Well, messing around with SSH is not something I want to do to my servers. Additionally, if I'm going to have the public SSH into my server I want to make sure it's ring-fenced. With a Docker container, it's even more ring-fenced then just SSHing directly into the server.

Live Demo

Want to see how it looks yourself? I've deployed this repository to a Hetzner Cloud server which is just running Docker.

Requirements

This project is in early access, and I'm quite new to Docker so please consider contributing if you think this could be improved! Please share your thoughts in the issues/discussions. Thank you!

Installation

To get started, run the following Composer create-project command. Make sure to rename the ssh-app-name to the name of your project.

After the command has been run, enter the directory it just created.

Getting Started

You will have the following directory structure. Here is an explanation of all the important files.

You may choose to keep the tests and the .github folder. If you don't use/need code style or PHP stan these can be uninstalled by removing them from composer.json and running composer update.

Building your SSH TUI (Terminal UI)

Now you have a great baseline for building your SSH TUI, go build something awesome.

In the src directory, you will find an index.php file. This file is the entry point for your SSH app. You can choose to do anything you like with this. This template has pre-installed laravel/prompts and joetannenbaum/chewie to demonstrate how it can be used.

You may also consider installing nunomaduro/termwind which is a fantastic tool that lets you write HTML in the terminal.

Here are some useful resources for getting started:

Running the script during development

During development, it's recommended to run the script with the following command:

Running the SSH server

Obviously, you're going to want to see the SSH server right before your eyes! You can do this by running the following command.

This will run the SSH server in your terminal window. In another window, you should be able to run the following command

Installing additional PHP extensions

You may need to add additional extensions to get your server to work in production. You can do this by modifying the Dockerfile in the root directory. The base image runs Alpine Linux and has a few common PHP extensions, however you can add more here if you need.

Deploying to production

Requirements

Your server must have Docker installed.

Configuring Everything

Firstly, copy the docker-compose.yml file to docker-compose.prod.yml and open it up. Inside here, change the ports from 2201:22 to 22:22. This will mean on production your app will run on the regular SSH port. You may also need to define the platform to build on.

Changing the default OpenSSH port on your server

Next, we're going to need to change the OpenSSH port on your server to something other than 22, because that's what our application will be running on. On your server run:

Look for the line that starts with Port. It may be commented out, go ahead and uncomment it. Change it to whatever number you'd like (and is available), for example 2201. Then restart the service with the following command

Now you want to update your firewall rules to ensure that the port is not blocked. Depending on which firewall you are using, this may be different for you. For ufw:

[!CAUTION] Important: Before you log out of the server or close that terminal tab, open a new terminal and make sure you can access your server via SSH. If it doesn't work you will be locked out of your server, so remaining logged in in the original tab will allow you to remedy any issues.

Next time you need to SSH into your server you can specify the custom port.

If you're using Laravel Forge on this server, make sure you change the port that Forge connects to the server with under Settings > Server Settings > SSH Port.

Clone your project onto the server

Make sure you commit your docker-compose.prod.yml file and then deploy the whole project to your server.

Deploy time!

Now you can run the following command on your server. Run the following ./deploy.sh script.

If it is the first time running the above deploy script, you may need to make it executable.

If you are using Laravel Forge, you can add this to your deployment script to automatically update the SSH app.

It's completely normal for this command to exit after running. If you want to check that the Docker container is running, you can run the following command

And that's it! ✨

Now you can SSH into your server ssh your-server-ip and you should see your awesome PHP application! You can even point your DNS to the server IP and use that too if you like.

Official Docker Repository

This project uses the sammyjo20/ssh-php Dockerfile. You can see this Dockerfile and contribute by following the link below.

https://github.com/sammyjo20/ssh-php-docker

Support

If you found this project useful, please consider sponsoring me either one time or a regular sponsor. This helps pay me for my time maintaining and keeping projects like these active. You can sponsor me on GitHub by clicking here.

Credits

Security

If you find any security related issues, please send an email to [email protected]


All versions of ssh-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
laravel/prompts Version ^0.1.24
joetannenbaum/chewie Version ^0.1.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sammyjo20/ssh-php contains the following files

Loading the files please wait ....