{"id":18084714,"url":"https://github.com/coderofsalvation/middleware-remoteshell","last_synced_at":"2025-04-06T00:12:38.314Z","repository":{"id":57296851,"uuid":"333805894","full_name":"coderofsalvation/middleware-remoteshell","owner":"coderofsalvation","description":"allow developers to tail logs remotely using curl (and run cmds)","archived":false,"fork":false,"pushed_at":"2021-02-03T13:26:36.000Z","size":27,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T14:34:41.591Z","etag":null,"topics":["cli","express","http","middleware","polka"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/coderofsalvation.png","metadata":{"files":{"readme":"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}},"created_at":"2021-01-28T15:48:02.000Z","updated_at":"2022-09-11T15:00:12.000Z","dependencies_parsed_at":"2022-09-01T13:01:54.364Z","dependency_job_id":null,"html_url":"https://github.com/coderofsalvation/middleware-remoteshell","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Fmiddleware-remoteshell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Fmiddleware-remoteshell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Fmiddleware-remoteshell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Fmiddleware-remoteshell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderofsalvation","download_url":"https://codeload.github.com/coderofsalvation/middleware-remoteshell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247415975,"owners_count":20935387,"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":["cli","express","http","middleware","polka"],"created_at":"2024-10-31T15:07:45.396Z","updated_at":"2025-04-06T00:12:38.269Z","avatar_url":"https://github.com/coderofsalvation.png","language":"JavaScript","readme":"## express remoteshell\n\nallow developers to tail logs remotely using curl (and run cmds):\n\n```sh\n$ node test/polka.js \n[rshell] for terminal access run: $ curl -sSNT. localhost:8080 -u username:password\n\u003e Running on localhost:3000\n\n$ curl \u003csomeurl\u003e\nwelcome..beep..boop\n\nmyapp $ ls\nstdout\nstderr\nmyapp $ stdout\n23-01 13:10:12 log: hello world from console.log\n```\n\n## Usage\n\napp.js:\n\n```javascript\nconst polka = require('polka');\nconst port = 8080\n \nconst rshell = require('middleware-remoteshell')({\n    port,\n    welcome:  `welcome..beep..boop..\\n\\n`,\n    prompt: 'myapp $ ', \n    userpass: (process.env.RSHELL_USERS||'').split(\",\"),\n    allowed: (req,res) =\u003e String(req.headers['user-agent']).match(/curl\\//) \u0026\u0026 rshell.userpass.length, \n    interactive: true,\n    oncmd: (i) =\u003e {\n        let error = null\n        let cmd   = i.cmd.trim()\n        if( cmd.match(/(stderr|stdout)/) ){\n            rshell.clients[i.id][cmd] = !rshell.clients[i.id][cmd]\n            if( cmd == 'stdout' ) return i.cb(error, 'stdout toggled')\n            if( cmd == 'stderr' ) return i.cb(error, 'stderr toggled')\n        }\n        if( cmd == 'ls'     ) return i.cb(error, 'stdout\\nstderr')\n        i.cb(error, \"unknown cmd: \"+i.cmd)\n    }\n})\nrshell.start()\n\napp.use( rshell.middleware )\n// see test/polka.js or test/express.js for the full picture \n```\n## Host it somewhere \n\n**Only** host this locally, or through an SSL proxy, SSH tunnel or intranet.\u003cbr\u003e\nSimple HTTP allows password sniffing (oops!) . \n\n```bash\n$ RSHELL_USERS=\"admin:admin,john:doe\" node app.js\nlistening at 8080\n[rshell] for terminal access run: $ curl -sSNT. localhost:8080 -u admin:admin\n```\n\n## Meanwhile somewhere else \n\n```javascript\n$ curl -sSNT. localhost:8080 -u admin:admin \n\n$ alias myapp=\"curl -sSNT. localhost:8080 -u admin:admin | stdbuf -i0 -o0 -e0 tr -d '\\000'\"\n\nwelcome..beep..boop..\n\n01-28 15:45:45 log: test\n01-28 15:45:45 err: this is an example error\n01-28 15:45:46 log: test\n01-28 15:45:46 err: this is an example error\n01-28 15:45:47 log: test\n01-28 15:45:47 err: this is an example error\n\n```\n\n```javascript\n$ curl -sSNT. localhost:8080 -u admin:admin | grep err:\n01-28 15:45:45 err: this is an example error\n01-28 15:45:46 err: this is an example error\n01-28 15:45:47 err: this is an example error\n\n```\n\n## Tips\n\n* craft commands using [dashdash](https://npmjs.org/dashdash)\n* create a bash-script to easily teleport into various apps:\n\n```\n#!/bin/bash\nmyapp(){  curl -sSNT. myapp.foo.com -u admin | stdbuf -i0 -o0 -e0 tr -d '\\000'\" }\nappfoo(){ curl -sSNT. foo.com       -u admin | stdbuf -i0 -o0 -e0 tr -d '\\000'\" }\n\n[[ ! -n \"$1\" ]] \u0026\u0026 { echo \"apps: \\n$(cat $0 | fgrep '(){' | head -n-1 | sed 's/(){.*//g' )\" \u0026\u0026 exit; }\n\n\"$@\"\n```\n\n## Test development\n\n```javascript\n$ npm install polka express\n$ node test/express.js\n$ node test/polka.js\n```\n\n## Credits \n\n* @TooTallNate for pointing out the curl trick\n* @mk-pmb for pointing out the `stdbuf` trick\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderofsalvation%2Fmiddleware-remoteshell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderofsalvation%2Fmiddleware-remoteshell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderofsalvation%2Fmiddleware-remoteshell/lists"}