Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's a few thoughts that might help.</p> <p><strong>Sub-shells</strong></p> <p>Sub-shells fork new processes, but don't return control to the calling shell. If you want to fork a sub-shell to do the work for you, then you'll need to append a <code>&amp;</code> to the line.</p> <p><code>(ssh username@domain) &amp;</code></p> <p>But this doesn't look like a compelling reason to use a sub-shell. If you had a number commands you wanted to execute in order from each other, yet in parallel from the calling shell, then maybe it would be worth it. For example...</p> <p><code>(dothis.sh; thenthis.sh; andthislastthingtoo.sh) &amp;</code></p> <p><strong>Forking</strong></p> <p>I'm not sure why <code>&amp;</code> isn't working for you, but it may be worth looking into <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Nohup" rel="nofollow"><code>nohup</code></a> as well. This makes the command "immune" to hang up signals.</p> <p><code>nohup ssh username@domain</code> (try with and without the <code>&amp;</code> at the end)</p> <p><strong>Passwords</strong></p> <p>Not storing passwords in the script is essential for any ssh automation. You can accomplish that using public key cryptography which is an inherent feature of ssh. I wont go into the details here because there are a <a href="http://pkeck.myweb.uga.edu/ssh/" rel="nofollow">number</a> <a href="https://wiki.archlinux.org/index.php/Using_SSH_Keys" rel="nofollow">of</a> <a href="http://www.debian-administration.org/article/SSH_with_authentication_key_instead_of_password" rel="nofollow">great</a> <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Secure_Shell" rel="nofollow">resources</a> all across the interwebs on setting this up. I strongly suggest investigating this further.</p> <ul> <li><a href="http://pkeck.myweb.uga.edu/ssh/" rel="nofollow"><em>HOWTO: set up ssh keys</em> - Paul Keck, 2001</a></li> <li><a href="https://wiki.archlinux.org/index.php/Using_SSH_Keys" rel="nofollow"><em>SSH Keys</em> - archlinux.org</a></li> <li><a href="http://www.debian-administration.org/article/SSH_with_authentication_key_instead_of_password" rel="nofollow"><em>SSH with authentication key instead of password</em> - Debian Administration</a></li> <li><a href="https://secure.wikimedia.org/wikipedia/en/wiki/Secure_Shell" rel="nofollow"><em>Secure Shell</em> - Wikipedia, the free encyclopedia</a></li> </ul> <p>If you do go this route, I also suggest running ssh in "batch mode" which will disable password querying and will automatically disconnect from the server if it becomes unresponsive after 5 minutes.</p> <p><code>ssh -o 'BatchMode=yes' username@domain</code></p> <p><strong>Persistence</strong></p> <p>Then if you want to persist the connection, run some silly loop in bash! :)</p> <p><code>ssh -o 'BatchMode=yes' username@domain "while (( 1 == 1 )); do sleep 60; done"</code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload