{"id":18548569,"url":"https://github.com/sammyjo20/ssh-php","last_synced_at":"2025-04-09T10:05:22.610Z","repository":{"id":250354654,"uuid":"834211035","full_name":"Sammyjo20/ssh-php","owner":"Sammyjo20","description":"The ridiculously simple starting point for building PHP SSH apps! 🔥","archived":false,"fork":false,"pushed_at":"2024-09-27T16:55:44.000Z","size":74,"stargazers_count":256,"open_issues_count":0,"forks_count":12,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-02T08:07:36.968Z","etag":null,"topics":["php","ssh","tui"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sammyjo20.png","metadata":{"files":{"readme":".github/README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-26T16:58:41.000Z","updated_at":"2025-03-23T02:52:22.000Z","dependencies_parsed_at":"2024-11-06T20:39:26.435Z","dependency_job_id":"fc741a5c-33d8-4f20-a3cd-2009fb0f4cb7","html_url":"https://github.com/Sammyjo20/ssh-php","commit_stats":null,"previous_names":["sammyjo20/ssh-php"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sammyjo20%2Fssh-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sammyjo20%2Fssh-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sammyjo20%2Fssh-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sammyjo20%2Fssh-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sammyjo20","download_url":"https://codeload.github.com/Sammyjo20/ssh-php/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248018060,"owners_count":21034048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","ssh","tui"],"created_at":"2024-11-06T20:34:59.401Z","updated_at":"2025-04-09T10:05:22.583Z","avatar_url":"https://github.com/Sammyjo20.png","language":"PHP","funding_links":["https://github.com/sponsors/sammyjo20"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# 🤫  _`SSH PHP` !_\n\n### The ridiculously simple starting point for building PHP SSH apps! 🔥\n\n\u003cimg width=\"974\" alt=\"Screenshot 2024-07-26 at 18 09 49\" src=\"https://github.com/user-attachments/assets/be2d197d-b574-418d-9a6d-76d3b3d4b667\"\u003e\n\n\u003c/div\u003e\n\n## What the shell?!\n\nI 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](https://joe.codes/) 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](https://github.com/charmbracelet/wish) running with PHP to work with Docker!\n\nThis is project is mainly for building [TUIs](https://en.wikipedia.org/wiki/Text-based_user_interface) however it can run any PHP script so you can build cool forms, resumes or anything you desire!\n\n## Why Docker?\n\nWell, 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.\n\n## Requirements\n- PHP 8.3 (Installed locally)\n- Docker\n\n\u003e 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!\n\n## Installation\n\nTo get started, run the following Composer `create-project` command. Make sure to rename the `ssh-app-name` to the name of your project.\n\n```\ncomposer create-project sammyjo20/ssh-php ssh-app-name\n```\n\nAfter the command has been run, enter the directory it just created.\n\n## Getting Started\nYou will have the following directory structure. Here is an explanation of all the important files.\n\n```\n.\n├── .github            # Contains workflows for running tests, PHP Stan and Code Style Fixers.\n├── src                # Your application's source files\n├── tests              # Automated tests (PEST)\n├── docker-compose.yml # This file will be used to deploy your application to production.\n└── Dockerfile         # This file allows you to customise the production image and add extra PHP extensions.\n```\nYou 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`.\n\n### Building your SSH TUI (Terminal UI)\nNow you have a great baseline for building your SSH TUI, go build something awesome.\n\nIn 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](https://github.com/laravel/prompts) and [joetannenbaum/chewie](https://github.com/joetannenbaum/chewie) to demonstrate how it can be used.\n\nYou may also consider installing `nunomaduro/termwind` which is a fantastic tool that lets you write HTML in the terminal.\n\nHere are some useful resources for getting started:\n- [Joe Tannenbaum - Hacking Laravel Prompts For Fun \u0026 Profit](https://blog.joe.codes/hacking-laravel-prompts-for-fun-and-profit)\n- [Joe Tannenbaum - Building TUIs Gotchas \u0026 Good Info](https://blog.joe.codes/building-tuis-gotchas-and-good-info)\n- [Laravel Prompts Documentation](https://laravel.com/docs/11.x/prompts#main-content)\n- [joetannenbaum/chewie Documentation](https://github.com/joetannenbaum/chewie)\n\n### Running the script during development\nDuring development, it's recommended to run the script with the following command:\n\n```\nphp ./src/index.php \n```\n\n### Running the SSH server\nObviously, you're going to want to see the SSH server right before your eyes! You can do this by running the following command.\n\n```\ncomposer run-dev\n```\nThis will run the SSH server in your terminal window. In another window, you should be able to run the following command\n\n```\nssh localhost -p 2201\n```\n\n### Installing additional PHP extensions\nYou may need to add additional extensions to get your server to work in production. You can do\nthis by modifying the `Dockerfile` in the root directory. The base image runs Alpine Linux and\nhas a few common PHP extensions, however you can add more here if you need.\n\n```\nRUN apk add php-redis\n```\n\n## Deploying to production\n\n### Requirements\nYour server must have Docker installed.\n\n### Configuring Everything\nFirstly, 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.\nYou may also need to define the platform to build on.\n\n### Changing the default OpenSSH port on your server\nNext, 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:\n\n```\nsudo nano /etc/ssh/sshd_config\n```\n\nLook 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\n\n```\nsudo service ssh restart\n```\n\nNow 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:\n\n```\nsudo ufw allow 2201/tcp\n```\n\u003e [!CAUTION]\n\u003e 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.\n\nNext time you need to SSH into your server you can specify the custom port.\n\n```\nssh user@your-server -p 2201\n```\n\nIf you're using [Laravel Forge](https://forge.laravel.com) on this server, make sure you change the port that Forge connects to the server with under Settings \u003e Server Settings \u003e SSH Port.\n\n### Clone your project onto the server\nMake sure you commit your `docker-compose.prod.yml` file and then deploy the whole project to your server.\n\n### Deploy time!\nNow you can run the following command on your server. Run the following `./deploy.sh` script.\n\nIf it is the first time running the above deploy script, you may need to make it executable.\n\n```\nchmod u+x ./deploy.sh\n```\n\n```\n./deploy.sh\n```\n\u003e If you are using Laravel Forge, you can add this to your deployment script to automatically update the SSH app.\n\nIt'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\n\n```\ndocker ps\n```\n## And that's it! ✨\nNow 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.\n\n```\nssh your-server-ip\n```\n\n## Official Docker Repository\nThis project uses the `sammyjo20/ssh-php` Dockerfile. You can see this Dockerfile and contribute by following the link below.\n\nhttps://github.com/sammyjo20/ssh-php-docker\n\n## Support\nIf 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](https://github.com/sponsors/sammyjo20).\n\n## Credits\n- Huge thanks to [Joe Tannenbaum's](https://joe.codes/) for his awesome [blog post](https://blog.joe.codes/creating-ssh-apps-with-charm-wish-and-laravel-prompts) and his support via Twitter/X DMs!\n\n## Security\nIf you find any security related issues, please send an email to 29132017+Sammyjo20@users.noreply.github.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsammyjo20%2Fssh-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsammyjo20%2Fssh-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsammyjo20%2Fssh-php/lists"}