Skip to content

Failed SFTP write doesn't cause task failure (using ssh-agent) #51

Closed
@junglebarry

Description

@junglebarry

Hi,

I'm trying to SFTP some files up to a server through an SSH tunnel. The tunnel connects correctly, but my user doesn't have permissions to write the file to the server. (Yes, I should use a privileged user, but that's not the issue here.)

I would expect the sftp task to fail, but instead it succeeds, after printing an error message. This is in --verbose mode:

Connection :: connect
copying foo.zip to /path/foo.zip
>> Error: Permission denied
Connection :: end
Connection :: close

Done, without errors.

I may have misunderstood what you can and cannot do through an ssh-agent connection, but is there any way to force the task to fail under these circumstances?

It's not a problem for manual runs, but I was hoping to use this in an automated deployment system, where discovering failure is imperative.

Here's my config (credentials withheld, obviously):

"sftp": {
  "staging": {
    "options": {
      "ignoreErrors": false, // this didn't seem to work
      "showProgress": true,
      "agent": process.env.SSH_AUTH_SOCK,
      "username": "<%= deployment.username %>",
      "host": "<%= deployment.host %>",
      "path": "<%= deployment.paths.staging %>"
    },
    "files": {
      "<%= pkg.name %>.zip": "<%= pkg.name %>.zip"
    }
  }
}

Activity

davidjbradshaw

davidjbradshaw commented on Mar 21, 2014

@davidjbradshaw
Contributor

Is the issue that your trying to write to /path/foo.zip, when you want to write to path/foo.zip?

I just submitted a patch that might fix that issue.

junglebarry

junglebarry commented on May 15, 2014

@junglebarry
Author

Hi @davidjbradshaw I don't believe so. I have a deployment path specified (which is essentially a subdirectory of /tmp on my server) and the files are written relative to that.

My deployments have been working seamlessly until today (I haven't changed anything on my side), but the issue is being raised with different circumstances:

Running "sftp:staging" (sftp) task
Verifying property sftp.staging exists in config...OK
Files: whisk_app_v2.tar.bz2 -> whisk_app_v2.tar.bz2
Options: path="", host=false, username=false, password=false, agent="", port=22, minimatch={}, srcBasePath="", createDirectories=false, directoryPermissions=493, showProgress=false, config="whisk", readyTimeout=30000
Raw Options: path="", host=false, username=false, password=false, agent="", port=22, minimatch={}, srcBasePath="", createDirectories=false, directoryPermissions=493, showProgress=false, config="whisk", readyTimeout=30000
Verifying property sshconfig.whisk exists in config...OK
Options: path="/tmp/", host="MYHOSTGOESHERE", username="MYUSERNAMEGOESHERE", password=false, agent="/tmp/launch-UfG6cf/Listeners", port=22, minimatch={}, srcBasePath="", createDirectories=false, directoryPermissions=493, showProgress, config="whisk", readyTimeout=30000, ignoreErrors=false
Connection :: connect
>> Connection :: error :: Error: Timed out while waiting for handshake
Connection :: close

Done, without errors.

Again, the error is probably something on my side; my concern here is the "Done, without errors" part at the end.

Incidentally, it doesn't seem to be waiting 30000 milliseconds before the timeout occurs - it's more like 10 seconds. I've tried altering that in both my generic config and in sftp-specific setup (as you can see above) to no avail. Should I raise a separate ticket for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Failed SFTP write doesn't cause task failure (using ssh-agent) · Issue #51 · israelroldan/grunt-ssh