Bash Script: What does this mean? "done </ dev / null & disown"
Could you explain what exactly the last line does and why it is necessary?
while true; do /usr/bin/ssh -R 55555:localhost:22 -i ~/.ssh/tunnel-id user@server.com sleep 1 done < /dev/null & disown This is the whole script, and it is intended to create an SSH tunnel on the relay server. I'm new to Bash, but it looks like it will constantly try to keep in touch, but I don't understand the syntax of the last line.
This script is part of the process of using SSH behind a firewall or in my case NAT: http://martin.piware.de/ssh/index.html
The last line redirects /dev/null to the loop as input - which immediately returns EOF - and starts the process in the background. He then runs the disown (1) command in the foreground, which separates the process, preventing the HUP signals from stopping it (sort of like nohup). the effect is to make the loop something like a daemon process.
In the general loop, the ssh command is executed once per second. The command opens the ssh tunnel, connecting it locally to port 5555 and remotely to port 22 (ssh). If there is something there to connect, it is; otherwise, the redirected EOF terminates it. Then he tries to attack a second later.
(Or, I think I haven't really tried.)
In bash, disconnection is built-in; use help disown to see some details.
Redirecting /dev/null to the while effectively closes its stdin , which should be equivalent to exec <&- .