What's new

Simple beginner questions about using SSH with Merlin

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

NB_8

Occasional Visitor
As a complete beginner with SSH I am wondering:

1) If one would like to use SSH scripts to make persistent changes to the way Merlin functions, can a user enable SSH in Merlin, run a script, then disable SSH (and even remove the SSH client completely), and have the script still functioning?

Or would the user need to keep SSH enabled in Merlin and keep the SSH client running for as long as they would like the script to remain functioning?

2a) Do SSH scripts alter the firmware or configuration?

2b) If a user makes a mistake with an SSH script and they restore a saved router configuration that was made prior to running the script, will the script then be absent?

3) Is there an SSH client that is recommended over the standard or portableapps version of Putty?
 
1) That depends on how the script is written or invoked. When most scripts are run they maintain connections to the terminal session's input and output streams. Disconnecting the terminal session typically creates an error within a running script causing it to terminate. There are ways to stop this happening though.

2a) Again it depends on the script in question. Some scripts change the router's configuration settings, some don't. Scripts don't alter the firmware though.

2b) Scripts are stored in the /jffs/scripts directory. The contents of this directory will still be there as it is separate from the configuration settings. If you have a script that's causing problems you can disable the automatic running of all scripts in the GUI.
 
There is no such thing as an SSH script. You're conflating scripting (which uses an interpreter, typically bash or some variant) w/ SSH (a terminal program). You use SSH to interact w/ the router in realtime, which may include the execution of scripts. As @ColinTaylor points out, there are implications as to how scripts behave when invoked in this fashion, specifically wrt input/output streams. But you could just as well have the system invoke your scripts as part of the bootup process, or the scheduler (i.e., cron/cru). And if the router supported it, use something other than SSH as your terminal program (e.g., telnet).
 
If you have a script that's causing problems you can disable the automatic running of all scripts in the GUI.
I'm assuming this would be done by disabling the the "Enable JFFS Custom Scripts..." option. If so, would doing that affect the JFFS directory other that not allowing scripts to run?

I'd like to utilize two scripts that eibgrad had shared: a firewall rule to prevent WAN traffic leaks prior to the OpenVPN client connecting (https://www.snbforums.com/threads/kill-switch-doesnt-work.74948/post-715885); and a watchdog script (https://www.snbforums.com/threads/a...onnected-right-after-reboot.74660/post-713934).

Based on comments in this thread, it seems an SSH client would likely need to maintain connection to keep these scripts active. Alternatively the task scheduler of a router-connected system could be used to run scripts.

Are there any alternative ways to have these scripts stay active in a persistent way that would not depend on a separate system with scheduled tasks or a terminal program being constantly connected to the router?
 
I'm assuming this would be done by disabling the the "Enable JFFS Custom Scripts..." option.
Correct.
If so, would doing that affect the JFFS directory other that not allowing scripts to run?
No.
Based on comments in this thread, it seems an SSH client would likely need to maintain connection to keep these scripts active.
No. He has written those scripts so that they insert code into firewall-start and services-start. Those custom scripts are run automatically by the router (if enabled in the GUI) and are independent of any SSH sessions.
 
I'm assuming that any code-inserting scripts such as those I linked in post#5 would be wiped out if a user performs a modem reset. Correct?

I'm not sure if scripts such as those I linked in post#5 are kept in the JFFS directory. However, I imagine that any code-inserting scripts or scripts residing in the JFFS directory would be wiped out by a reset.
 
I'm assuming that any code-inserting scripts such as those I linked in post#5 would be wiped out if a user performs a modem reset. Correct?

I'm not sure if scripts such as those I linked in post#5 are kept in the JFFS directory. However, I imagine that any code-inserting scripts or scripts residing in the JFFS directory would be wiped out by a reset.
What model router do you have?
 
3) Is there an SSH client that is recommended over the standard or portableapps version of Putty?
Adding to @MamyPoko's post, more info from Microsoft for using OpenSSH can be found here.
 
What model router do you have?
I'm going to need to double check, but it is one of the currently supported Merlin models.

Are there differences among currently supported models in regards to wiping code-inserting scripts and the JFFS directory by doing a reset?
 
Probably not but I can only speak for the models I'm familiar with. Ascertaining which router and firmware version you have really should have been the very first thing I asked. :rolleyes:
 
Probably not but I can only speak for the models I'm familiar with. Ascertaining which router and firmware version you have really should have been the very first thing I asked. :rolleyes:
Understood. Well if anyone is able to comment to their best knowledge whether currently supported models will wipe code-inserting scripts and the JFFS directory by doing a reset, that would honestly be helpful.
 
Why not just state what model router you have and which firmware version it is running? That way we can avoid any potential confusion.
 
Why not just state what model router you have and which firmware version it is running? That way we can avoid any potential confusion.
I know we set it up with the latest firmware, but it's in a shared office space I have not been going in to lately for health reasons.
 
I know we set it up with the latest firmware, but it's in a shared office space I have not been going in to lately for health reasons.
In which case all we can say is that just doing a normal reset should not wipe out any scripts stored in jffs. It will however stop them running as it would reset "Enable JFFS Custom Scripts..." to No.
 
In which case all we can say is that just doing a normal reset should not wipe out any scripts stored in jffs. It will however stop them running as it would reset "Enable JFFS Custom Scripts..." to No.
Would any code-inserting scripts such as those linked in post#5 also be stopped as a result of setting "Enable JFFS Custom Scripts..." to "No"?
 
Would any code-inserting scripts such as those linked in post#5 also be stopped as a result of setting "Enable JFFS Custom Scripts..." to "No"?
Those particular scripts are designed to be run just once so that they can modify the relevant JFFS custom scripts. Once run they do not need to be run again (unless you reformat the jffs partition).
 
Those particular scripts are designed to be run just once so that they can modify the relevant JFFS custom scripts. Once run they do not need to be run again (unless you reformat the jffs partition).
I appreciate the reply, however it is still unclear to me whether scripts such as those linked in post#5 would be stopped as a result of setting "Enable JFFS Custom Scripts..." to "No".
 
I appreciate the reply, however it is still unclear to me whether scripts such as those linked in post#5 would be stopped as a result of setting "Enable JFFS Custom Scripts..." to "No".

If you're referring to my scripts, they would be stopped. The "Enable JFFS Custom Scripts" field refers to *any* scripts that are called as a result of the event model managed by the router. IOW, there are certain events that occur during the operation of the router. If you've installed a specifically named script into the /jffs/scripts directory for that event (e.g., firewall-start, called immediately after the firewall is (re)initialized), the router will execute that script. Just so long as you have "Enable JFFS Custom Scripts" set to Yes. Set it to No, and any such scripts are ignored. But that doesn't prevent YOU from executing those scripts from SSH, or using the scheduler (cron/cru), if you feel so inclined.

 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top