SSH | Is it possible to put Working Directory as optional?

Hello,

I am trying to do an SSH connection to a clish and then execute a command. The SSH node expects a working directory to be specified, however because it is a clish, cd is not allowed and an error is returned.

Is it possible to make the Working Directory optional?

Hi @anfilma, welcome to the community!

This is a really good suggestion, make sure to also vote on it yourself!

I also found the working directory setting frustrating when connecting to Windows hosts, though I could get it to work by setting its value to null (the actual null value, not the string) like so: Issue - n8n Docker container crash - SSH to Windows machine - #5 by MutedJam

Perhaps you can test this for your server as well?

Thanks for the reply @MutedJam!

I tried that suggestion and it works! Thank you! Another solution is to put the Working Directory as an expression and then leave empty, it work too.

When I execute a command I receive an error “Failed in tcgetattr(). : Inappropriate ioctl for device” and with some research found out that an argument -tt in the ssh command will work (for example ssh -tt [email protected]…). Is it possible to put arguments in the ssh node?

Hi @anfilma, that’s not an option I am aware of unfortunately, so I think this is indeed a feature request for now :frowning:

Hi @MutedJam, Is it possible to implement this feature? If so, when do you expect it to be implemented?

Thanks a lot!

Hey @anfilma,

What SSH sever implementation are you working with? Adding support for forcing tty allocation sounds like a bad idea to me as it will cause issues. When you force tty the session won’t know how to handle interactive responses (password prompts, confirmation dialogs) so it will just sit there connected waiting.

A better solution for this one is to mark the working directory as optional as previously mentioned. As for when it would be implemented and if it is possible… It is possible to add it but timelines depend on the popularity of the request although if we are working on a node anyway we may pull in some of the feature requests.

I do have a ticket opened to look into an issue with the SSH node so I can try and fit this in at the same time but it will likely be a few weeks until I get there.

Hello @Jon,

What I am trying to do is execute a specific command in an interactive shell (“clish” shell).

For instance, I’m trying to run the command ssh -t [email protected] address ‘vpn tu del vpn_ip username’. This vpn command is a checkpoint shell that allows you to block vpn communications.

The vpn command cannot be executed without the -t parameter because ssh node does not open a normal shell.

Hey @anfilma,

Normally with an interactive option you would want to interact with a response which is not something that is currently possible with n8n as we open the session fire off the command then close it rather than waiting for user input so using the example you have provided if we were to enable the force tty option and you just ran the vpn command it would just stay there waiting for an input that will never happen.

It sounds like from your previous testing not having a working directory set would allow you to run the command and clish would be able to build out the paths as needed from it’s environment files. If this option won’t work for you though it will likely take longer to check if it is possible as we would need to check the package we use to see if it supports the option and do some testing to make sure it won’t lead to any unexpected issues.

As the feature request is open though it will just be a case of waiting until we have some resource to assign to this one, As a temporary solution depending on how you have n8n configured you could SSH to the host running n8n then SSH from there to the clish session.

1 Like