{"id":5841,"date":"2017-12-21T11:28:49","date_gmt":"2017-12-21T19:28:49","guid":{"rendered":"https:\/\/www.bigtreestech.com\/wp2013\/?p=5841"},"modified":"2017-12-22T13:09:05","modified_gmt":"2017-12-22T21:09:05","slug":"pita","status":"publish","type":"post","link":"https:\/\/www.bigtreestech.com\/wp2013\/pita\/","title":{"rendered":"PITA!"},"content":{"rendered":"<p>I spent all morning figuring out how to get the remote execution of Python scripts working.\u00a0 What a PITA!<\/p>\n<p>It turns out that when you log in through SSH, or in my case SFTP, you get handed a completely PATH environment variable that if you log in locally or through a Virtual Private Network.\u00a0 That results in the remote system not being able to find commands that it normally as access to via modifications to the user&#8217;s .profile or .bashrc files.\u00a0 When coming in through sftp, none of those modifications are read or applied.<\/p>\n<p>I tried many things and finally got it working by:<\/p>\n<ol>\n<li>\u00a0Creating a .ssh directory in each user&#8217;s home directory.<\/li>\n<li>\u00a0Adding an environment file in each of the new .ssh directories which included the desired PATH definition for that user.<\/li>\n<li>edit the \/etc\/ssh\/sshd_config file so that <span class=\"codeblock\">PermitUserEnvironment<\/span> is set to yes<\/li>\n<li>restart SSH.<\/li>\n<li>change the ownership and group for any files I want to execute to the logged in user.<\/li>\n<\/ol>\n<p>Now, I can use pysftp to execute any properly formatted python programs that can be found on the new PATH.<\/p>\n<p>I could have executed the programs by simply using the full path to the program in the sftp.execute command (as long as permissions were set correctly) but I wanted a cleaner solution.<\/p>\n<p>What I have done would not be the most secure setup if there were actually different users but in my situation I am all the users so no big deal.\u00a0 The potential security issue is because now each user can alter their SSH environment variables.<\/p>\n<p>By the way, connecting up the sensor won&#8217;t happen until at least 12\/22 because some of the required parts have been delayed.\u00a0 If UPS decides the roads are too icy for them it may not happen for a few days.<\/p>\n<p>Glad I got it working!\u00a0 I need a break!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I spent all morning figuring out how to get the remote execution of Python scripts working.\u00a0 What a PITA! It turns out that when you log in through SSH, or in my case SFTP, you get handed a completely PATH &hellip; <a class=\"more-link\" href=\"https:\/\/www.bigtreestech.com\/wp2013\/pita\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[259],"tags":[],"class_list":["post-5841","post","type-post","status-publish","format-standard","hentry","category-snow-depth-project"],"_links":{"self":[{"href":"https:\/\/www.bigtreestech.com\/wp2013\/wp-json\/wp\/v2\/posts\/5841","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bigtreestech.com\/wp2013\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bigtreestech.com\/wp2013\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bigtreestech.com\/wp2013\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bigtreestech.com\/wp2013\/wp-json\/wp\/v2\/comments?post=5841"}],"version-history":[{"count":1,"href":"https:\/\/www.bigtreestech.com\/wp2013\/wp-json\/wp\/v2\/posts\/5841\/revisions"}],"predecessor-version":[{"id":5842,"href":"https:\/\/www.bigtreestech.com\/wp2013\/wp-json\/wp\/v2\/posts\/5841\/revisions\/5842"}],"wp:attachment":[{"href":"https:\/\/www.bigtreestech.com\/wp2013\/wp-json\/wp\/v2\/media?parent=5841"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bigtreestech.com\/wp2013\/wp-json\/wp\/v2\/categories?post=5841"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bigtreestech.com\/wp2013\/wp-json\/wp\/v2\/tags?post=5841"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}