{"id":14385221,"url":"https://github.com/MCluck90/simple-ssh","last_synced_at":"2025-08-23T18:31:54.555Z","repository":{"id":9511875,"uuid":"11407882","full_name":"MCluck90/simple-ssh","owner":"MCluck90","description":"A simple wrapper for Brian White's ssh2 module to make it easier to perform sequential commands.","archived":false,"fork":false,"pushed_at":"2022-12-11T14:29:49.000Z","size":96,"stargazers_count":194,"open_issues_count":13,"forks_count":37,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-04-13T21:56:55.236Z","etag":null,"topics":["javascript","ssh","ssh2"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MCluck90.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-07-14T19:15:46.000Z","updated_at":"2024-01-31T16:59:38.000Z","dependencies_parsed_at":"2023-01-11T20:12:33.852Z","dependency_job_id":null,"html_url":"https://github.com/MCluck90/simple-ssh","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/MCluck90/simple-ssh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MCluck90%2Fsimple-ssh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MCluck90%2Fsimple-ssh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MCluck90%2Fsimple-ssh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MCluck90%2Fsimple-ssh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MCluck90","download_url":"https://codeload.github.com/MCluck90/simple-ssh/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MCluck90%2Fsimple-ssh/sbom","scorecard":{"id":87461,"data":{"date":"2025-08-11","repo":{"name":"github.com/MCluck90/simple-ssh","commit":"39c13db386ae0cdbef762cb1de951889a6d5b4f3"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.1,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":3,"reason":"Found 7/21 approved changesets -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: MIT License: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 16 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"14 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-j383-35pm-c5h4","Warn: Project is vulnerable to: GHSA-rm36-94g8-835r","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-qrpm-p2h7-hrv2","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5","Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6","Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj","Warn: Project is vulnerable to: GHSA-652h-xwhf-q4h6"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-15T07:14:06.873Z","repository_id":9511875,"created_at":"2025-08-15T07:14:06.873Z","updated_at":"2025-08-15T07:14:06.873Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271762974,"owners_count":24816843,"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","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["javascript","ssh","ssh2"],"created_at":"2024-08-28T18:02:02.455Z","updated_at":"2025-08-23T18:31:54.309Z","avatar_url":"https://github.com/MCluck90.png","language":"JavaScript","readme":"**Note:** *I really don't work on this project anymore. It's still fully functional, I'm just not interested in working on it anymore. If you post an issue, I might respond and I might not. If you submit a pull request, I'll most likely accept it. Hopefully it continues to help people around the world.* :earth_americas:\n\n# simple-ssh\n\nA wrapper for the [ssh2 client module by Brian White][1] which makes it easier to run a sequence of commands over SSH.\n\n# Requirements\n\n* [node.js][2] -- v0.8.7 or newer\n\n# Install\n\n    npm install simple-ssh\n\n# Examples\n\n* Echoing out a users `PATH`:\n\n```javascript\nvar SSH = require('simple-ssh');\n\nvar ssh = new SSH({\n    host: 'localhost',\n    user: 'username',\n    pass: 'password'\n});\n\nssh.exec('echo $PATH', {\n    out: function(stdout) {\n        console.log(stdout);\n    }\n}).start();\n\n/*** Using the `args` options instead ***/\nssh.exec('echo', {\n    args: ['$PATH'],\n    out: function(stdout) {\n        console.log(stdout);\n    }\n}).start();\n```\n\n* Connecting with the active SSH Agent with Agent Forwarding\n\n```javascript\nvar ssh = new ssh({\n    host: 'localhost',\n    user: 'username',\n    agent: process.env.SSH_AUTH_SOCK,\n    agentForward: true\n})\n```\n\n* Capturing error output:\n\n```javascript\nssh.exec('this-does-not-exist', {\n    err: function(stderr) {\n        console.log(stderr); // this-does-not-exist: command not found\n    }\n}).start();\n```\n\n* Capturing error codes:\n\n```javascript\nssh.exec('exit 69', {\n    exit: function(code) {\n        console.log(code); // 69\n    }\n}).start();\n```\n\n* Sending data to stdin:\n\n```javascript\nssh.exec('cat \u003e /path/to/remote/file', {\n   in: fs.readFileSync('/path/to/local/file')\n}).start();\n```\n\n* Chaining commands together:\n\n```javascript\nssh\n    .exec('echo \"Node.js\"', {\n        out: console.log.bind(console)\n    })\n    .exec('echo \"is\"', {\n        out: console.log.bind(console)\n    })\n    .exec('echo \"awesome!\"', {\n        out: console.log.bind(console)\n    })\n    .start();\n\n// Output:\n// Node.js\n// is\n// awesome!\n```\n\n* Get the number of commands:\n\n```javascript\nssh\n    .exec('exit 1')\n    .exec('exit 2')\n    .exec('exit 3');\n\nconsole.log(ssh.count()); // 3\n```\n\n* Running a command using `sudo`\n\n```javascript\nssh.exec('sudo echo \"Pseudo-sudo\"', {\n    pty: true,\n    out: console.log.bind(console)\n}).start();\n```\n\n* Resetting a connection and the commands\n\n```javascript\n// Echos out any messages the user sent in if 10 or more have been queued\nvar msgInterval = setInterval(function() {\n    if (ssh.count() \u003e 10) {\n        ssh.start();\n    }\n}, 1000);\n\nsocket.on('message', function(msg) {\n    // If a 'reset' message is received, clear previous messages\n    if (msg === 'reset') {\n        ssh.reset(function(err) {\n            if (err) {\n                throw err;\n            }\n\n            ssh.exec('echo \"reset\"');\n        });\n    } else {\n        ssh.exec('echo \"' + msg + '\"');\n    }\n});\n```\n\n* Listening for additional events\n\n```javascript\nssh.on('error', function(err) {\n    console.log('Oops, something went wrong.');\n    console.log(err);\n    ssh.end();\n});\n```\n\n* Event handlers can be chained as well\n\n```javascript\nssh\n    .on('error', onSSHError)\n    .on('ready', onSSHReady);\n```\n\n----------\n\n# API\n\n### Functions\n\n* **Constructor**( [ _config_ ] )\n    * **config** { _Object_ }:\n        * **config.host** {  _String_ }: Hostname\n        * **config.port** { _Number_ }: Port number (default: `22`)\n        * **config.user** { _String_ }: Username\n        * **config.pass** { _String_ }: Password\n        * **config.timeout** { _Number_ }: Connection timeout in milliseconds (default: `10000`)\n        * **config.key** { _String_ }: SSH key\n        * **config.passphrase** { _String_ }: Passphrase\n        * **config.baseDir** { _String_ }: Base directory. If this is set, each command will be preceeded by `cd ${this.baseDir}`\n        * **config.agent** { _String_ }: Connects with the given SSH agent. If this is set, no need to specify a private key or password.\n        * **config.agentForward** { _Boolean_ }: Set to true to connect with agent forwarding.\n* **exec**( _command_, [ _options_ ] ): **Adds a command to the stack**\n    * **command** { _String_ }: Command to be executed\n    * **options** { _Object_ }:\n        * **options.args** { _String[]_ }: Additional command line arguments (default: `null`)\n        * **options.in** { _String_ }: Input to be sent to `stdin`\n        * **options.out** { _Function( stdout )_ }: `stdout` handler\n            * **stdout** { _String_ }: Output streamed through `stdout`\n        * **options.err** { _Function( stderr )_ }: `stderr` handler\n            * **stderr** { _String_ }: Output streamed through `stderr`\n        * **options.exit** { _Function( code, stdout, stderr )_ }: Exit handler\n            * **code** { _Number_ }: Exit code\n            * **stdout** { _String_ }: All of the standard output concatenated together\n            * **stderr** { _String_ }: All of the error output concatenated together\n        * **options.pty** { _Boolean_ }: Allocates a pseudo-tty, useful for command which require `sudo` (default: `false`)\n* **on**( _event_, _callback_ ): **Add a listener for the specified event** (Courtesy of [@alexjab][3])\n    * **event** { _String_ }: Event to listen to\n    * **callback** { _Function_ }: Executed on the event\n* **start**( [ _options_ ] ): **Starts executing the commands**\n    * **options** { _Object_ }:\n        * **options.success** { _Function()_ }: Called on successful connection\n        * **options.fail** { _Function( err )_ }: Called if the connection failed\n            * **err** { _Error_ }: Error information\n* **reset**( [ _callback_ ] ): **Clears the command queue and resets the current connection**\n    * **callback** { _Function( err )_ }: Called when the connection has been successfully reset\n        * **err** { _Error_ }: Error information\n* **end**(): **Ends the SSH session** (this is automatically called at the end of a command queue).\n\n### Properties\n\n* **host** { _String_ }: Host to connect to\n* **port** { _Number_ }: Port to connect through (default: `22`)\n* **user** { _String_ }: User name\n* **pass** { _String_ }: Password\n* **timeout** { _Number_ }: Connection timeout in milliseconds (default: `10000`)\n* **key** { _String_ }: SSH key\n* **baseDir** { _String_ }: If set, will change directory to `baseDir` before each command\n\n### Flow Control\n\nSometimes you may find yourself needing to change which commands are executed. The flow can be changed by returning `false` from an `exit` handler.\n\n**Note**: This only works if `false` is explicitly returned. \"Falsy\" values are not sufficient (since `undefined` is implicitly returned and it's \"falsy\").\n\n* Ending prematurely:\n\n```javascript\nssh\n    .exec('pwd', {\n        exit: function() {\n            return false;\n        }\n    })\n    .exec('echo \"Not executed\"')\n    .start();\n```\n\n* Running a new queue of commands:\n\n```javascript\nssh\n    .exec('exit', {\n        args: [ Math.round(Math.random()) ],\n        exit: function(code) {\n            if (code === 1) {\n                // Setup the new command queue\n                ssh.exec('echo \"new queue\"');\n                return false;\n            }\n        }\n    })\n    .exec('exit 0', {\n        exit: function() {\n            console.log('Previous command did not return false');\n        }\n    })\n    .start();\n```\n\n  [1]: https://github.com/mscdex/ssh2\n  [2]: http://nodejs.org\n  [3]: https://github.com/alexjab\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMCluck90%2Fsimple-ssh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMCluck90%2Fsimple-ssh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMCluck90%2Fsimple-ssh/lists"}