Skip to content

Commit

Permalink
Merge pull request #1 from narekhovhannisyan/pass-connection-expire
Browse files Browse the repository at this point in the history
Pass connection expire to node ssh extra instance
  • Loading branch information
narekhovhannisyan authored Jan 13, 2020
2 parents 6f36652 + e674d33 commit d0ce08f
Show file tree
Hide file tree
Showing 7 changed files with 743 additions and 4,952 deletions.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# node-ssh-extra

[![Build Status](https://travis-ci.com/narekhovhannisyan/node-ssh-extra.svg?branch=master)](https://travis-ci.com/narekhovhannisyan/node-ssh-extra)


[Node SSH](https://github.com/steelbrain/node-ssh) wrapper which helps to reuse existing connections.

All connections are kept in cache and expire after given `connectionExpire` milliseconds.

## Usage

### For separate servers.
```
const NodeSSHExtra = require('node-ssh-extra')
NodeSSHExtra({
privateKey, // Private key path for ssh connection.
host, // name for ssh connection.
passphrase, // Passphrase for ssh connection.
username, // User name for ssh connection.
connectionExpire, // Milliseconds to expire ssh connections.
domainOrIP // Domain or IP address to connect.
})
.then((connection) => {
// Do whatever you need to do here.
})
```

### If all servers have the same connection credentials.

```
const NodeSSHExtra = require('node-ssh-extra').NodeSSHExtraForSameCredentials({
privateKey,
host,
passphrase,
username,
connectionExpire
})
NodeSSHExtra('mock-domain.com')
.then((connection) => {
// Do whatever you need to do here.
})
// And after if you need to do some other thing with new connection just call NodeSSHExtra the same way.
NodeSSHExtra('mock-domain.com')
.then((connection) => {
// Just continue doing what you need :)
})
```
9 changes: 9 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"checkJs": true
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
}
Loading

0 comments on commit d0ce08f

Please sign in to comment.