January 3, 20215 yr New to unraid. I have a command like this: ssh -R 8000:XX.XX.XX.XX:8000 [email protected] If i write this command in the Terminal window in unraid it works, obviously. But if i close this Terminal window in unraid, this tunnel is closed, obviously. Is there any tool to fire this event... ... in the background ... at a start of unraid system? I came across the User-Scripts Plugin and tried to fix this problem with script like that #!/usr/bin/expect -f spawn ssh -N -R 8000:XX.XX.XX.XX:8000 [email protected] & expect "Password:*" send "XXXXX\r" expect eof exit And it works, but not "really" in the background. The tunnel cannot be open... Maybe i just forgot something in the script or just can use another Tool... I don't know.
January 3, 20215 yr Community Expert I'm no expert at this at all, but can't you just use screen? Then the tunnel should stay open until you choose to close it or detach from screen. Screen is in nerdpack IIRC.
January 3, 20215 yr Author Okay, so you are not an expert? ;). It is working via Terminal, perfect. Now any idea how to put this in a startup-script?
January 3, 20215 yr Community Expert Actually I have no idea, I'm no good at programing. But maybe this works: #!/bin/bash screen -d -m ssh -N -R 8000:XX.XX.XX.XX:8000 [email protected] & expect "Password:*" send "XXXXX\r" expect eof exit According to the screen manual the -d -m option: Quote -d -m Start screen in detached mode. This creates a new session but doesn’t attach to it. This is useful for system startup scripts. And just set user script to run at array start? If it works then you need some more commands to kill it when you want.
January 3, 20215 yr A slightly simpler way to get what you want might be: 1. Write a short script that just prints the password ("echo mygoodpassword"). Assume you put it at /root/mypass. 2. In /boot/config/go, add: DISPLAY=: SSH_ASKPASS=/root/mypass setsid ssh -N -R 8000:XX.XX.XX.XX:8000 [email protected]
January 5, 20215 yr You actually want to be using private keys and the builtin background capability of SSH I'll assume you known how to generate private+public key pairs else see this for a primer When you are sure the keys are working correctly (generate them without passphrase encryption) and can ssh to the other server without being prompted for anything, Try the ssh command below (which will be exact command you stick into your script or go file) #!/bin/bash ssh -f -i path/to/ssh/private.key -R 8000:xxx.xxx.xxx.xxx:8000 [email protected]
January 5, 20215 yr Author Ken-ji, you are totally right. I will do this change this of course. First, i struggled with these two problemes: 1. How to start a script, in the background, to open a tunnel (forever). 2. Go-Script or User-Scripts. For for now, i think with the go file it working.
Archived
This topic is now archived and is closed to further replies.