{"id":157,"date":"2016-09-14T20:39:47","date_gmt":"2016-09-14T20:39:47","guid":{"rendered":"http:\/\/www.web-workers.ch\/?p=157"},"modified":"2017-05-06T21:26:23","modified_gmt":"2017-05-06T21:26:23","slug":"how-to-execute-bash-script-on-a-remote-host-and-get-the-output-locally","status":"publish","type":"post","link":"https:\/\/www.web-workers.ch\/index.php\/2016\/09\/14\/how-to-execute-bash-script-on-a-remote-host-and-get-the-output-locally\/","title":{"rendered":"How to execute bash-script on a remote host and get the output locally"},"content":{"rendered":"<ol>\n<li>Make sure you have <a href=\"http:\/\/www.web-workers.ch\/index.php\/2016\/05\/15\/how-to-authenticate-passwordless-via-ssh\/\">enabled passwordless SSH logins<\/a> to the remote host.<\/li>\n<li>Use\u00a0<em>bash<\/em>\u00a0to load environment variables that are required by the remote-script<br \/>\n<code>ssh root@$10.37.25.145\u00a0bash -c \"\/local\/app\/myscript.sh\"<\/code><\/li>\n<li>Or use the command in a bash-script<br \/>\n<code>RESULT=`ssh root@10.37.25.145 bash -c \"\/local\/app\/myscript.sh\"`<br \/>\n<\/code><code>echo ${RESULT}<\/code><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Make sure you have enabled passwordless SSH logins to the remote host. Use\u00a0bash\u00a0to load environment variables that are required by the remote-script ssh root@$10.37.25.145\u00a0bash -c &#8220;\/local\/app\/myscript.sh&#8221; Or use the command [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":160,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[63,77,43,52,41,44,48,57],"class_list":["post-157","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-ad","tag-bash","tag-http","tag-log","tag-php","tag-root","tag-script","tag-ssh"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.web-workers.ch\/wp-content\/uploads\/2016\/09\/ssh-everywhere1.png?fit=500%2C300&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8sxjX-2x","jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/posts\/157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/comments?post=157"}],"version-history":[{"count":3,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/posts\/157\/revisions"}],"predecessor-version":[{"id":161,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/posts\/157\/revisions\/161"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/media\/160"}],"wp:attachment":[{"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/media?parent=157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/categories?post=157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.web-workers.ch\/index.php\/wp-json\/wp\/v2\/tags?post=157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}