Members
getConnReady
runMultiple
Executes a set of multiple and sequential commands.
Methods
ensureEmptyDir(server, remotePath, then)
Ensure a remote directory exists and is empty
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
remotePath |
String | |
then |
callback(err, ServerCredentials server, ssh2.Client conn) |
ensureEmptyDirSudo(server, remotePath, then)
Ensure a remote directory exists and is empty
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
remotePath |
String | |
then |
callback(err, ServerCredentials server, ssh2.Client conn) |
ensureFileContains(server, remoteFile, contain, then)
Ensure a remote file contains a certain text piece of text
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
remoteFile |
String | |
contain |
String | |
then |
callback(contains, err, ServerCredentials server, ssh2.Client conn) |
ensureFileContainsSudo(server, remoteFile, contain, then)
Ensure a remote file contains a certain text piece of text
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
remoteFile |
String | |
contain |
String | |
then |
callback(contains, err, ServerCredentials server, ssh2.Client conn) |
ensureOwnership(server, remotePath, then)
Ensure a file belongs to connected user
by sudo chmod -R /path
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
remotePath |
String | |
then |
callback(err, ServerCredentials server, ssh2.Client conn) |
exec(server, cmd, doneEach, done)
Executes a command and return its output
like child_process.exec.
non-interactive
also take care of
- remote program termination with ctrl+C
If cmd is an array of string,
they are executed in serie,
respective output of each stdout / stderr is join then returned.
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
cmd |
String|[String] | |
doneEach |
callback(bool err, String stdout, String stderr, ServerCredentials server, ssh2.Client conn) | |
done |
callback(bool err, String stdout, String stderr, ServerCredentials server, ssh2.Client conn) |
execOne(server, cmd, done)
Executes a command and return its output
like child_process.exec.
non-interactive
also take care of
- remote program termination with ctrl+C
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
cmd |
String | |
done |
callback(bool err, String stdout, String stderr, ServerCredentials server, ssh2.Client conn) |
fileExists(server, remoteFile, then)
Tells if a file exists on remote
by trying to open handle on it.
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
remoteFile |
String | |
then |
callback(err, exists, ServerCredentials server, ssh2.Client conn) |
fileExistsSudo(server, remoteFile, then)
Tells if a file exists on remote
by trying to open handle on it.
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
remoteFile |
String | |
then |
callback(err, exists, ServerCredentials server, ssh2.Client conn) |
getDir(server, remotePath, localPath, allDone)
Downloads a remote directory to the local.
remote traverse directories over sftp.
then get files in parallel
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
remotePath |
String | |
localPath |
String | |
allDone |
callback(err, ServerCredentials server, ssh2.Client conn) |
getFile(server, remoteFile, localPath, then)
Downloads a file to the local
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
remoteFile |
String | |
localPath |
String | |
then |
callback(err, ServerCredentials server, ssh2.Client conn) |
mkdir(server, remotePath, then)
Creates a remote directory
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
remotePath |
String | |
then |
callback(err, ServerCredentials server, ssh2.Client conn) |
mkdirSudo(server, remotePath, then)
Creates a remote directory
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
remotePath |
String | |
then |
callback(err, ServerCredentials server, ssh2.Client conn) |
mktemp(server, suffix, then)
Creates a concurrent-safe temporary remote directory.
It does not attempt to keep track of temp files created during the session.
Thus it won t delete them on connection close.
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
suffix |
String | |
then |
callback(err, tmpDirName, ServerCredentials server, ssh2.Client conn) |
putDir(server, localPath, remotePath, then)
Uploads a local directory to the remote.
Partly in series, partly parallel.
Proceed such
sudo rm -fr /remotePath
sudo mkdir -p /remotePath
recursive sftp mkdir
recursive sftp put
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
localPath |
String | |
remotePath |
String | |
then |
callback(err, ServerCredentials server, ssh2.Client conn) |
putDirSudo(server, localPath, remotePath, then)
Uploads a local directory to the remote.
Partly in series, partly parallel.
Proceed such
sudo rm -fr /remotePath
sudo mkdir -p /remotePath
recursive sftp mkdir
recursive sftp put
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
localPath |
String | |
remotePath |
String | |
then |
callback(err, ServerCredentials server, ssh2.Client conn) |
putFile(server, localFile, remoteFile, then)
Uploads a file on the remote remote
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
localFile |
String | |
remoteFile |
String | |
then |
callback(err, ServerCredentials server, ssh2.Client conn) |
putFileSudo(server, localFile, remoteFile, then)
Uploads a file on the remote via sudo support
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
localFile |
String | |
remoteFile |
String | |
then |
callback(err, ServerCredentials server, ssh2.Client conn) |
readFile(server, remoteFile, then)
Reads a file on the remote
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
remoteFile |
String | |
then |
callback(err, ServerCredentials server, ssh2.Client conn) |
readFileSudo(server, remoteFile, then)
Reads a file on the remote via sudo
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
remoteFile |
String | |
then |
callback(err, ServerCredentials server, ssh2.Client conn) |
rmdir(server, remotePath, then)
Deletes a file or directory
rm -fr /some/path
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
remotePath |
String | |
then |
callback(err, ServerCredentials server, ssh2.Client conn) |
rmdirSudo(server, remotePath, then)
Deletes a file or directory
sudo rm -fr /some/path
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
remotePath |
String | |
then |
callback(err, ServerCredentials server, ssh2.Client conn) |
run(server, cmd, doneEach, done)
Executes a command and return its stream,
like of child_process.spawn.
interactive
also take care of
- manage sudo cmd
- log errors to output
If cmd is an array, they are executed in serie,
the pipe is open asap,
you ll receive each stdout stderr data in serie
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
cmd |
String|[String] | |
doneEach |
callback(bool err, String stdout, String stderr, ServerCredentials server, ssh2.Client conn) | |
done |
callback(bool err, Stream stdout, Stream stderr, ServerCredentials server, ssh2.Client conn) |
streamReadFile(server, remoteFile, then)
Reads a large file on the remote
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
remoteFile |
String | |
then |
callback(err, Stream data, ServerCredentials server, ssh2.Client conn) |
streamReadFileSudo(server, remoteFile, then)
Reads a large file on the remote via sudo
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
remoteFile |
String | |
then |
callback(err, Stream data, ServerCredentials server, ssh2.Client conn) |
writeFile(server, remoteFile, content, then)
Writes content to a remote file
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
remoteFile |
String | |
content |
String | |
then |
callback(err, ServerCredentials server, ssh2.Client conn) |
writeFileSudo(server, remoteFile, content, then)
Writes content to a remote file
Parameters:
Name | Type | Description |
---|---|---|
server |
ServerCredentials|ssh2.Client | |
remoteFile |
String | |
content |
String | |
then |
callback(err, ServerCredentials server, ssh2.Client conn) |