{"id":5282,"date":"2024-02-06T21:16:10","date_gmt":"2024-02-07T03:16:10","guid":{"rendered":"https:\/\/www.incredigeek.com\/home\/?p=5282"},"modified":"2024-02-06T21:16:10","modified_gmt":"2024-02-07T03:16:10","slug":"run-sudo-command-over-ssh-single-line","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/run-sudo-command-over-ssh-single-line\/","title":{"rendered":"Run sudo Command over SSH.  Single line."},"content":{"rendered":"\n<p>When running an SSH command that uses sudo, something like<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ssh admin@192.168.1.20 \"sudo apt -y update &amp;&amp; sudo apt -y upgrade\"<\/pre>\n\n\n\n<p>You may receive the following error.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper<br>sudo: a password is required<\/pre>\n\n\n\n<p>To work around this, you can use the -t option.  <em>-q is not needed, but makes thing quieter.<\/em><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ssh -qt admin@192.168.1.20 \"sudo apt -y update &amp;&amp; sudo apt -y upgrade \"<\/pre>\n\n\n\n<p>The sudo password will also be hidden.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><a href=\"https:\/\/unix.stackexchange.com\/questions\/134155\/how-do-you-keep-the-password-hidden-when-invoked-during-the-su-command\">https:\/\/unix.stackexchange.com\/questions\/134155\/how-do-you-keep-the-password-hidden-when-invoked-during-the-su-command<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/233217\/how-to-pass-the-password-to-su-sudo-ssh-without-overriding-the-tty\">https:\/\/stackoverflow.com\/questions\/233217\/how-to-pass-the-password-to-su-sudo-ssh-without-overriding-the-tty<\/a><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When running an SSH command that uses sudo, something like ssh admin@192.168.1.20 &#8220;sudo apt -y update &amp;&amp; sudo apt -y upgrade&#8221; You may receive the following error. sudo: a terminal is required to read the password; either use the -S &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/run-sudo-command-over-ssh-single-line\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[313,7,221,535],"class_list":["post-5282","post","type-post","status-publish","format-standard","hentry","category-linux","tag-command","tag-linux-2","tag-ssh","tag-sudo"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/5282","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=5282"}],"version-history":[{"count":3,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/5282\/revisions"}],"predecessor-version":[{"id":5616,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/5282\/revisions\/5616"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=5282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=5282"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=5282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}