{"id":7458,"date":"2021-02-10T22:46:47","date_gmt":"2021-02-10T21:46:47","guid":{"rendered":"https:\/\/michlstechblog.info\/blog\/?p=7458"},"modified":"2021-02-11T12:47:36","modified_gmt":"2021-02-11T11:47:36","slug":"linux-use-x11-forwarding-with-putty-and-su-sudo","status":"publish","type":"post","link":"https:\/\/michlstechblog.info\/blog\/linux-use-x11-forwarding-with-putty-and-su-sudo\/","title":{"rendered":"Linux: Use X11 forwarding with putty and su\/sudo"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_7458 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_7458')){$('.twoclick_social_bookmarks_post_7458').socialSharePrivacy({\"services\":{\"flattr\":{\"uid\":\"Michl\",\"status\":\"on\",\"the_title\":\"Linux%3A%20Use%20X11%20forwarding%20with%20putty%20and%20su%2Fsudo\",\"the_excerpt\":\"Hi%2C%0D%0A%0D%0Awhen%20you%20use%20X11%20forwarding%20with%20PuTTY%20or%20ssh%20-X%20a%20TCP%20Socket%20is%20opened%20to%20which%20each%20user%20can%20connect.%20The%20connection%20to%20the%20X11%20itself%20is%20protected%20by%20an%20authentification%20cookie.%0D%0A%0D%0AMeans%20when%20you%20add%20this%20cookie%20to%20the%20session%20launched%20by%20su%20you%20could%20use%20X11%20forwarding.%0D%0A%0D%0AAn%20example.%20Connect%20to%20a%20linux%20machine%20as%20user%20michael%20%28by%20putty%20or%20from%20another%20linux%20machine%29%0D%0A%0D%0A%5Bshell%5D%0D%0Amic%20...\",\"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-x11-forwarding-with-putty-and-su-sudo\\\/\",\"post_id\":7458,\"post_title_referrer_track\":\"Linux%3A+Use+X11+forwarding+with+putty+and+su%2Fsudo\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>Hi,<\/p>\n<p>when you use X11 forwarding with PuTTY or ssh -X a TCP Socket is opened to which each user can connect. The connection to the X11 itself is protected by an authentification cookie.<\/p>\n<p>Means when you add this cookie to the session launched by su you could use X11 forwarding.<\/p>\n<p>An example. Connect to a linux machine as user michael (by putty or from another linux machine)<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nmichael@debdev ~ # ssh -X michael@debdev1 \r\n<\/pre>\n<p>In the session of debdev1 list all xauth cookies.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nmichael@debdev1 ~ # xauth list\r\ndebdev1\/unix:10  MIT-MAGIC-COOKIE-1  7ea68cc88e74c1697aa6c757504fc0d7 \r\n<\/pre>\n<p>Note: these cookies are stored the users home directory in file .Xauthority => ~\/.Xauthority <\/p>\n<p>Then switch to another user on this machine<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nmichael@debdev1 ~ # sudo su helena\r\n<\/pre>\n<p>When you try to start a X11 client you got some errors like this<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nhelena@debdev1 ~ # xterm\r\nCan't connect to X11 window server using 'localhost:10.0' as the value of the DISPLAY variable.\r\n<\/pre>\n<p>Then verify you already have a ~\/.Xauthority file<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nhelena@debdev1 ~ # ls -l ~\/.Xauthority\r\n<\/pre>\n<p>If not create a new file<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nhelena@debdev1 ~ # touch ~\/.Xauthority\r\n<\/pre>\n<p>and add the authentification cookie<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nhelena@debdev1 ~ # xauth add debdev1\/unix:10  MIT-MAGIC-COOKIE-1  7ea68cc88e74c1697aa6c757504fc0d7\r\n<\/pre>\n<p>Then you should be able to start X11 programs<\/p>\n<p>Michael<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, when you use X11 forwarding with PuTTY or ssh -X a TCP Socket is opened to which each user can connect. The connection to the X11 itself is protected by an authentification cookie. Means when you add this cookie to the session launched by su you could use X11 forwarding. An example. Connect to &hellip; <a href=\"https:\/\/michlstechblog.info\/blog\/linux-use-x11-forwarding-with-putty-and-su-sudo\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Linux: Use X11 forwarding with putty and su\/sudo<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[870,3],"tags":[568,224,630,1529,1445,567],"class_list":["post-7458","post","type-post","status-publish","format-standard","hentry","category-debian","category-linux","tag-forwarding","tag-linux-2","tag-putty","tag-su","tag-sudo","tag-x11"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/7458","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=7458"}],"version-history":[{"count":3,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/7458\/revisions"}],"predecessor-version":[{"id":7461,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/7458\/revisions\/7461"}],"wp:attachment":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/media?parent=7458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/categories?post=7458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/tags?post=7458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}