Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I am not familiar with JSch. But if you have root access, you can update your sudoers configuration file to get around this. Add the following line to /etc/sudoers</p> <pre><code>Defaults:USERNAME_HERE !requiretty </code></pre> <p>Maybe someone else can elaborate on whether this is a bad idea or not, that's beyond the scope of my knowledge, but I'd love to know more? </p> <p>I only use this approcah in one specific situation. We have a cronjob that backs up a cluster of remote servers via rsync, but for rsync to run successfully, it needs sudo privileges. </p> <p>To get around this I did the following-</p> <ol> <li>Created a user "backupuser" - On both servers local &amp; remote</li> <li><p>Added the following two lines to /etc/sudoers - Only needed on the server you want to grant sudo privileges to the user on. In our case, only on the remote server.</p> <pre><code>backupuser ALL = NOPASSWD: /usr/bin/rsync DEFAULTS:backupuser !requiretty </code></pre></li> </ol> <p>Adding these two lines grants the user, 'backupuser' sudo privileges for rsync command without the need to enter a password and without the required tty connection. </p> <p>Here's how it works-</p> <p>The first line breaks down into two parts. </p> <pre><code>USER SPECIFICATION OPTION_TAG (: CONDITIONS(opt)) </code></pre> <ol> <li><p>USER SPECIFICATION - this sets the user that these options apply(s) too.</p> <pre><code>backupuser </code></pre></li> <li><p>OPTION_TAG - the tag for the option you what to grant. In this case, the user is granted sudo privileges without having the enter a password. (see <strong><em>man sudoers</em></strong> for a list of tags available)</p> <pre><code>ALL = NOPASSWD </code></pre></li> <li><p>CONDITIONS - You also have the option to place conditions on when to grant sudo privileges. In this case, the user only has sudo privileges to run the rsync command.</p> <pre><code>: /usr/bin/rsync </code></pre></li> </ol> <p>The second line, overrides the default requirement of the sudo command that you need a terminal connection to run sudo (tty requirement). And it grants this privilege only to the user account 'backupuser'. (See <strong><em>man sudoers</em></strong> for the other DEFAULTS)</p> <pre><code>DEFAULTS:backupuser !requiretty </code></pre> <p>Hope this helps answer your question. I know it went on a bit of a tangent, but I wanted to give a full explanation. For more info you can also checkout <strong><em>man sudo</em></strong></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