![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
New owner! Starting 12-23-2015, I (@israelroldan) am standing on the shoulders of two giants (@chuckmo and @andrewrjones) as maintainer of this project. Contributions are welcome as always. (This message will be removed on next release as well).
SSH and SFTP tasks for Grunt, using a pure JS implementation of ssh2.
This plugin requires Grunt ~0.4.0
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-ssh --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-ssh');
This library provides two Grunt tasks for ssh:
This plugin was designed to work with Grunt 0.4.x. If you're still using grunt v0.3.x it's strongly recommended that you upgrade, but in case you can't please use v0.1.0.
// don't keep passwords in source control
secret: grunt.file.readJSON('secret.json'),
sftp: {
test: {
files: {
"./": "*json"
},
options: {
path: '/tmp/',
host: '<%= secret.host %>',
username: '<%= secret.username %>',
password: '<%= secret.password %>',
showProgress: true
}
}
},
sshexec: {
test: {
command: 'uptime',
options: {
host: '<%= secret.host %>',
username: '<%= secret.username %>',
password: '<%= secret.password %>'
}
}
}
An example secret.json
might look like:
{
"host" : "myhost",
"username" : "username",
"password" : "**************"
}
Or, specifying SSH configurations for re-use, and referencing from tasks:
// don't keep passwords in source control
sshconfig: {
"myhost": grunt.file.readJSON('myhost.json')
},
sshexec: {
test: {
command: 'uptime',
options: {
config: 'myhost'
}
},
ls: {
command: 'ls -la',
options: {
config: 'myhost'
}
}
}
You can also overwrite the username
, password
, passphrase
or config
at runtime as a command line option:
$ grunt sshexec:someTask --config myhost --username foo
Copies one or more files to a remote server over ssh.
Inside your grunt.js
file add a section named sftp
.
object
The files to copy. Should contain key:value pairs.
If you would like to upload multiple files, use an array. For example:
files: {
"./": ["<%= dirs.css %>style.css","<%= dirs.css %>login.css","<%= dirs.css %>print.css"]
},
The following will not work:
files: {
"./": "<%= dirs.css %>style.css",
"./": "<%= dirs.css %>login.css",
"./": "<%= dirs.css %>print.css"
},
object
string
The path on the remote server. Defaults to /
.
object
Options for minimatch.
string
The username to authenticate as on remote system.
string
The remote host to copy to, set up in your ~/.ssh/config
.
number
The remote port, optional, defaults to 22
.
string
Optionally strip off an initial part of the file when performing the SFTP operation. This is a string operation, so trailing slashes are important.
For example:
/* [...] */
files: {
"./": "dist/**"
},
options: {
path: '/tmp/',
/* [...] */
srcBasePath: "dist/"
Would SFTP the files in dist directly into tmp (eg. dist/index.html
==> /tmp/index.html
)
boolean
Optionally check whether the directories files will be sftp'd to exist first. This can take a bit of extra time as directories need to be checked, so this option is disabled by default.
See also the directoryPermissions
option.
number
The permissions to apply to directories created with createDirectories. The default is 0755. JSHint will probably yell at you unless you set this using parseInt
:
directoryPermissions: parseInt(755, 8)
boolean
Show a progress bar during the file transfer. The default is false
.
integer
Size of each read in bytes (default: 32768)
function
Callback function called after command execution. Default: empty function
There are three mutually exclusive sets of connection options. They are
privateKey
(with optional passphrase
), password
, and agent
. If any of
these options are private, they will be tried exclusively, and other connection
options will be ignored. Each is described a bit more below.
string
A string containing the contents of the private key to use to authenticate with the remote system, you can load this from a file using grunt.file.read
. Be careful you don't put this into source control unless you mean it!
If a privateKey and passphrase are required, they
options: {
privateKey: grunt.file.read("id_rsa"),
passphrase: <%= secret.passphrase %>
}
string
The passphrase to use with the privateKey
. As per the privateKey
, do not expose this in your Gruntfile or anywhere that'll end up public unless you mean it, load it from an external file.
string
The password to authenticate on remote system.
string
Path to ssh-agent's UNIX socket for ssh-agent-based user authentication.
options: {
host: '<%= pkg.host %>',
port: '<%= pkg.port %>',
username: '<%= pkg.username %>',
agent: process.env.SSH_AUTH_SOCK
}
If you use jshint
, remember to add process: true
in globals
integer
How often (in milliseconds) to wait for the SSH handshake to complete.
Runs a command over ssh.
NOTE: To see the output of your sshexec
command locally, use the --verbose
flag.
Inside your grunt.js
file add a section named sshexec
.
string
or array
The command or commands to run, if an array is supplied, all the commands are executed on the same connection.
object
string
The username to authenticate as on remote system.
string
The remote host to copy to, set up in your ~/.ssh/config
.
number
The remote port, optional, defaults to 22
.
boolean/object
Set to true to allocate a pseudo-tty with defaults, or an object containing specific pseudo-tty settings (see 'Pseudo-TTY settings'). Setting up a pseudo-tty can be useful when working with remote processes that expect input from an actual terminal (e.g. sudo's password prompt).
boolean
Determins if the task should stop or continue if any of the commands returns a code other than 0. Disabled by default.
boolean
If true only display remote error messages if Grunt is run with the --verbose flag.
There are three mutually exclusive sets of connection options. They are
privateKey
(with optional passphrase
), password
, and agent
. If any of
these options are private, they will be tried exclusively, and other connection
options will be ignored. Each is described a bit more below.
string
A string containing the contents of the private key to use to authenticate with the remote system, you can load this from a file using grunt.file.read
. Be careful you don't put this into source control unless you mean it!
options: {
privateKey: grunt.file.read("id_rsa"),
passphrase: <%= secret.passphrase %>
}
string
The passphrase to use with the privateKey
. As per the privateKey
, do not expose this in your Gruntfile or anywhere that'll end up public unless you mean it, load it from an external file.
string
The password to authenticate on remote system.
string
Path to ssh-agent's UNIX socket for ssh-agent-based user authentication.
options: {
host: '<%= pkg.host %>',
port: '<%= pkg.port %>',
username: '<%= pkg.username %>',
agent: process.env.SSH_AUTH_SOCK
}
If you use jshint
, remember to add process: true
in globals
integer
How often (in milliseconds) to wait for the SSH handshake to complete.
sshexec runs each command individually, and it does not keep state of the previous command, so when you need to perform 2 commands or more , you could do e.g.:
sshexec: {
test: {
command: ['sh -c "cd /; ls; pwd"'],
options: {
host: '<%= secret.host %>',
username: '<%= secret.username %>',
password: '<%= secret.password %>'
}
}
}
sftp
improvements (Brian White; #64: Changed error handling for SFTP junglebarrychunkSize
option (Michael Lam); #51: Fix bad output on close (Eric Kever); #56: Add readyTimeout option for ssh2 connections (calebTomlinson).execCommand
(jabes).--debug
option is passed; Use latest version of ssh2 (0.2.14).sftp
and suppressRemoteErrors
option for sshexec
(David J. Bradshaw); #34: Use stat() instead of opendir() for checking existence of a dir (Harri Hälikkä); #38: Doc updates (Alexandre Richonnier).sshexec
.trim
options that may be read from files; Allow sshexec
to use ssh-agent-based user authentication (Andy Shinn).srcBasePath
(owenmead).srcBasePath
option to sftp
(marcins).Copyright (c) 2013 Andrew Jones. Licensed under the MIT license.
FAQs
SSH and SFTP tasks for Grunt
The npm package grunt-ssh receives a total of 948 weekly downloads. As such, grunt-ssh popularity was classified as not popular.
We found that grunt-ssh demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.