Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3490400
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:30:43+00:00 2026-05-18T11:30:43+00:00

Can you please explain exactly what the last line of this does, and why

  • 0

Can you please explain exactly what the last line of this does, and why it is needed?

while true; do
    /usr/bin/ssh -R 55555:localhost:22 -i ~/.ssh/tunnel-id user@server.com
    sleep 1
done < /dev/null & disown

That is the entire script, and it’s purpose is to create an SSH tunnel to a relay server. I’m new to Bash, but it looks like it will continually try to keep the connection alive, but I don’t understand the syntax of the last line.

This script is part of a process to use SSH behind a firewall, or in my case a NAT:
http://martin.piware.de/ssh/index.html

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T11:30:43+00:00Added an answer on May 18, 2026 at 11:30 am

    The last line redirects /dev/null into the loop as input — which immediately returns EOF — and runs the process in the background. It then runs a command disown(1) in the foreground, which detaches the process, preventing HUP signals from stopping it (sort of like nohup does.). the effect is to make the loop into something like a daemon process.

    The loop overall runs the ssh command once a second. The command is opening an ssh tunnel, connecting it locally to port 5555 and remotely to port 22 (ssh). If there is something there to connect, it does; otherwise the redirected EOF causes it to terminate. It then tries aagain a second later.

    (Or so I believe, I haven’t actually tried it.)

    In bash, disown is a built-in; use help disown to see some details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please explain what does the following line of code exactly do? If
can somebody please explain, what exactly does it mean? I'm trying to understand what
Can someone please explain the structure of this line of a script for me?
Can anyone please explain exactly what this code and its components are doing? I
Can anyone please explain exactly how the following code works, line by line. I'm
If this is the best (or a good) solution, can someone please explain exactly
Can someone please explain to me how this responsive approach works? This was done
Can anyone please explain me what delegateEvents in backbone.js does? The documentation did not
Can someone please explain this phenomenon? I am using Mojarra 2.1.6 - Glassfish 3.1.2.
Please see this image: Can someone explain the difference? Edit Let me indicate what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.