The shell2http is a command line tool that allows to provide shell commands or scripts as HTTP endpoints. Essentially, it creates a simple HTTP server that maps HTTP requests to shell commands. This can be particularly useful for creating lightweight APIs that execute shell commands in response to HTTP requests. This tutorial explains how to install shell2http on Ubuntu 24.04.
Install shell2http
Obtain the most recent shell2http version from its GitHub repository:
SHELL2HTTP_VERSION=$(curl -s "https://api.github.com/repos/msoap/shell2http/releases/latest" | grep -Po '"tag_name": "v\K[0-9.]+')
Download shell2http based on the version identified earlier:
wget -qO shell2http.tar.gz https://github.com/msoap/shell2http/releases/latest/download/shell2http_${SHELL2HTTP_VERSION}_linux_amd64.tar.gz
Unpack the executable to /usr/local/bin
:
sudo tar xf shell2http.tar.gz -C /usr/local/bin shell2http
To verify the shell2http version, we can use the command:
shell2http --version
Remove the unneeded downloaded file:
rm -rf shell2http.tar.gz
Testing shell2http
To use shell2http, start the HTTP server by specifying the endpoints and corresponding shell commands, such as:
shell2http /date "date" /ps "ps aux"
The command will map the /date
URL to execute the date
command and the /ps
URL to run the ps aux
command, making the command outputs accessible via HTTP requests.
In the browser, open http://localhost:8080
to see available endpoints.
Uninstall shell2http
To uninstall shell2http, delete the associated file:
sudo rm -rf /usr/local/bin/shell2http
Leave a Comment
Cancel reply