{"id":7084,"date":"2020-05-29T11:44:28","date_gmt":"2020-05-29T09:44:28","guid":{"rendered":"https:\/\/michlstechblog.info\/blog\/?p=7084"},"modified":"2020-05-29T12:48:19","modified_gmt":"2020-05-29T10:48:19","slug":"linux-use-ssh-agent-forwarding-while-sudo-to-another-user","status":"publish","type":"post","link":"https:\/\/michlstechblog.info\/blog\/linux-use-ssh-agent-forwarding-while-sudo-to-another-user\/","title":{"rendered":"Linux: Use ssh agent forwarding while sudo to another user"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_7084 social_share_privacy clearfix 1.6.4 locale-en_US sprite-en_US\"><\/div><div class=\"twoclick-js\"><script type=\"text\/javascript\">\/* <![CDATA[ *\/\njQuery(document).ready(function($){if($('.twoclick_social_bookmarks_post_7084')){$('.twoclick_social_bookmarks_post_7084').socialSharePrivacy({\"services\":{\"flattr\":{\"uid\":\"Michl\",\"status\":\"on\",\"the_title\":\"Linux%3A%20Use%20ssh%20agent%20forwarding%20while%20sudo%20to%20another%20user\",\"the_excerpt\":\"Hi%2C%0D%0A%0D%0Aif%20you%20are%20logged%20on%20as%20a%20user1%20and%20switch%20to%20another%20user2%20with%20sudo%20the%20ssh%20agent%20from%20user1%20cannot%20be%20used%20because%20the%20%22switched%22%20user2%20does%20nothing%20know%20about%20the%20ssh-agent%20respectively%20the%20agent%20socket.%0D%0A%20%28more%26hellip%3B%29\",\"txt_info\":\"2 clicks for more data protection:\\r\\n\\r\\nOnly when you click here, the button will be come active and you can send your recommendation to Flattr. When activating, data are transmitted to third parties. \",\"perma_option\":\"off\"}},\"txt_help\":\"When you activate these fields by clicking, information to Flattr may be transferred abroad, and probably may also stored there.\",\"settings_perma\":\"Enable permanently and accept data transmission. \",\"info_link\":\"http:\\\/\\\/www.heise.de\\\/ct\\\/artikel\\\/2-Klicks-fuer-mehr-Datenschutz-1333879.html\",\"uri\":\"https:\\\/\\\/michlstechblog.info\\\/blog\\\/linux-use-ssh-agent-forwarding-while-sudo-to-another-user\\\/\",\"post_id\":7084,\"post_title_referrer_track\":\"Linux%3A+Use+ssh+agent+forwarding+while+sudo+to+another+user\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>Hi,<\/p>\n<p>if you are logged on as a user1 and switch to another user2 with sudo the ssh agent from user1 cannot be used because the &#8220;switched&#8221; user2 does nothing know about the ssh-agent respectively the agent socket.<br \/>\n<!--more--><\/p>\n<p>The path to the agent socket is stored in the SSH_AUTH_SOCK environment variable. So you have to keep\/forward this variable to the switched user. This can be done by adding<\/p>\n<p><code><br \/>\nDefaults    env_keep+=SSH_AUTH_SOCK<br \/>\n<\/code><\/p>\n<p>to <strong>\/etc\/sudoers<\/strong><\/p>\n<p>Michael<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, if you are logged on as a user1 and switch to another user2 with sudo the ssh agent from user1 cannot be used because the &#8220;switched&#8221; user2 does nothing know about the ssh-agent respectively the agent socket.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[1447,1446,194,1445,1448,147],"class_list":["post-7084","post","type-post","status-publish","format-standard","hentry","category-linux","tag-agent","tag-forward","tag-ssh","tag-sudo","tag-sudo-user","tag-to"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/7084","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/comments?post=7084"}],"version-history":[{"count":5,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/7084\/revisions"}],"predecessor-version":[{"id":7095,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/7084\/revisions\/7095"}],"wp:attachment":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/media?parent=7084"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/categories?post=7084"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/tags?post=7084"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}