My 1st steps into the SSH Node, a few questions

Not long ago I discovered Terminal, SSH, CLI, nano and a host of other fun stuff in the techy world. Watching tutorials and asking questions has me doing some very basic tasks (like install n8n :smile:).

I have even created a workflow with the SSH nodes that executes a few basic CLI commands.

But now I need to go further.

Keeping in mind my very amateur skill level here, how can I use the SSH node (or other nodes if more are needed) to access my VPS, navigate to a folder, open a file with an editor like nano, make a few changes to that file and then save and exit the editor?

For example - if I needed to edit the domain url in file local.php

  1. Got to the directory cd /var/www/memtrk/app/config
  2. nano local.php to edit the file
  3. Edit site url inside that file to new domain but drop the s from http so its just http (The original domain will be consistent so I could use some kind of search and replace function)
  4. Save and exit the editor.

Hi @Robm, I hope you are well?

I suspect this won’t be possible using nano specifically (as it’s an interactive editor). In scripts but also an n8n workflow you’d typically want to use commands that just do their job and return a result, without requiring additional user input while running.

So you probably want to use sed instead for a job like replacing text in a file. A brief introduction would for example be available here. I’d suggest you get this to work directly via SSH first (maybe not using your production file /var/www/memtrk/app/config/local.php but a copy of the file during development). Once you have your command working the way you want it to, simply copy it over to n8n :slight_smile:

1 Like

Great, understand, rather execute scripts or commands via SSH than open and use an editor.

Thanks for the study resource, I will go to school and get this figured.

Thanks again for taking the time to assist @MutedJam


You can do that with N8N, but it’s not the right tool. You can do what you want with ansible, puppet or chef. Ansible is my favorite.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.