<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="http://brandonhutchinson.com/mediawiki/skins/common/feed.css?97"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title>X11 Forwarding and su/sudo - Revision history</title>
		<link>http://brandonhutchinson.com/mediawiki/index.php5?title=X11_Forwarding_and_su/sudo&amp;action=history</link>
		<description>Revision history for this page on the wiki</description>
		<language>en</language>
		<generator>MediaWiki 1.11.0rc1</generator>
		<lastBuildDate>Fri, 24 May 2013 13:01:15 GMT</lastBuildDate>
		<item>
			<title>Hutch at 17:31, 22 May 2008</title>
			<link>http://brandonhutchinson.com/mediawiki/index.php5?title=X11_Forwarding_and_su/sudo&amp;diff=1186&amp;oldid=prev</link>
			<description>&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 17:31, 22 May 2008&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 47:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 47:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; $ '''/usr/openwin/bin/xauth extract - host/unix:10 | sudo su - root -c &amp;quot;/usr/openwin/bin/xauth merge - ; DISPLAY=localhost:10.0 /usr/openwin/bin/xclock&amp;quot;'''&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; $ '''/usr/openwin/bin/xauth extract - host/unix:10 | sudo su - root -c &amp;quot;/usr/openwin/bin/xauth merge - ; DISPLAY=localhost:10.0 /usr/openwin/bin/xclock&amp;quot;'''&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you unable to use ''xauth'' in a pipeline (perhaps you are using sudo to become another user, but additional command line arguments are not allowed), run '''xauth list''' on the account you are sudo'ing from, sudo to the account, and add the appropriate key via '''xauth add'''.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you unable to use ''xauth'' in a pipeline (perhaps you are using sudo to become another user, but additional command line arguments are not allowed), run '''xauth list''' on the account you are sudo'ing from, sudo to the account, and add the appropriate key via '''xauth add''' &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;before starting your X client&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== Links ===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== Links ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</description>
			<pubDate>Thu, 22 May 2008 17:31:42 GMT</pubDate>			<dc:creator>Hutch</dc:creator>			<comments>http://brandonhutchinson.com/wiki/Talk:X11_Forwarding_and_su/sudo</comments>		</item>
		<item>
			<title>Hutch at 17:31, 22 May 2008</title>
			<link>http://brandonhutchinson.com/mediawiki/index.php5?title=X11_Forwarding_and_su/sudo&amp;diff=1185&amp;oldid=prev</link>
			<description>&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 17:31, 22 May 2008&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 46:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 46:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; localhost:10.0&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; localhost:10.0&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; $ '''/usr/openwin/bin/xauth extract - host/unix:10 | sudo su - root -c &amp;quot;/usr/openwin/bin/xauth merge - ; DISPLAY=localhost:10.0 /usr/openwin/bin/xclock&amp;quot;'''&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; $ '''/usr/openwin/bin/xauth extract - host/unix:10 | sudo su - root -c &amp;quot;/usr/openwin/bin/xauth merge - ; DISPLAY=localhost:10.0 /usr/openwin/bin/xclock&amp;quot;'''&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you unable to use ''xauth'' in a pipeline (perhaps you are using sudo to become another user, but additional command line arguments are not allowed), run '''xauth list''' on the account you are sudo'ing from, sudo to the account, and add the appropriate key via '''xauth add'''.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== Links ===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== Links ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</description>
			<pubDate>Thu, 22 May 2008 17:31:16 GMT</pubDate>			<dc:creator>Hutch</dc:creator>			<comments>http://brandonhutchinson.com/wiki/Talk:X11_Forwarding_and_su/sudo</comments>		</item>
		<item>
			<title>Hutch: New page: From my system with an Xorg X server, I login to ''host'' via ssh with X11 forwarding and execute an X client.   $ '''ssh hutch@host'''  (host) $ '''echo $DISPLAY'''  localhost:10.0  (host...</title>
			<link>http://brandonhutchinson.com/mediawiki/index.php5?title=X11_Forwarding_and_su/sudo&amp;diff=565&amp;oldid=prev</link>
			<description>&lt;p&gt;New page: From my system with an Xorg X server, I login to ''host'' via ssh with X11 forwarding and execute an X client.   $ '''ssh hutch@host'''  (host) $ '''echo $DISPLAY'''  localhost:10.0  (host...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;From my system with an Xorg X server, I login to ''host'' via ssh with X11 forwarding and execute an X client.&lt;br /&gt;
&lt;br /&gt;
 $ '''ssh hutch@host'''&lt;br /&gt;
 (host) $ '''echo $DISPLAY'''&lt;br /&gt;
 localhost:10.0&lt;br /&gt;
 (host) $ '''/usr/openwin/bin/xclock'''&lt;br /&gt;
&lt;br /&gt;
This works. What if I want to run an X client as the root user?&lt;br /&gt;
&lt;br /&gt;
 (host) $ '''/bin/su -'''&lt;br /&gt;
 # '''echo $DISPLAY'''&lt;br /&gt;
 &lt;br /&gt;
 # '''DISPLAY=localhost:10.0 /usr/openwin/bin/xclock'''&lt;br /&gt;
 X11 connection rejected because of wrong authentication.&lt;br /&gt;
 X connection to localhost:10.0 broken (explicit kill or server shutdown).&lt;br /&gt;
&lt;br /&gt;
This doesn't work because the X client is looking for the authority file in ''~root/.Xauthority'', while the needed credentials (i.e., the &amp;quot;magic cookie&amp;quot;) created by ssh are in ''~hutch/.Xauthority''.&lt;br /&gt;
&lt;br /&gt;
From SSH(1):&lt;br /&gt;
&lt;br /&gt;
     ssh will also automatically set up Xauthority data on the server machine.&lt;br /&gt;
     For this purpose, it will generate a random authorization cookie, store&lt;br /&gt;
     it in Xauthority on the server, and verify that any forwarded connections&lt;br /&gt;
     carry this cookie and replace it by the real cookie when the connection&lt;br /&gt;
     is opened.  The real authentication cookie is never sent to the server&lt;br /&gt;
     machine (and no cookies are sent in the plain).&lt;br /&gt;
&lt;br /&gt;
To make this work, set ''XAUTHORITY=~hutch/.Xauthority'' and execute the X client.&lt;br /&gt;
 # DISPLAY=localhost:10.0 XAUTHORITY=/home/hutch/.Xauthority /usr/openwin/bin/xclock&lt;br /&gt;
&lt;br /&gt;
This won't work if the root user cannot read ''/home/hutch/.Xauthority'', which would happen if the ''/home'' file system is on an NFS share and the root user is &amp;quot;squashed,&amp;quot; or mapped to the ''nobody'' user.&lt;br /&gt;
&lt;br /&gt;
If this is the case, use ''xauth'' in a pipeline to copy the user's credentials into the ''root'' user's authority file.&lt;br /&gt;
&lt;br /&gt;
''su'' example:&lt;br /&gt;
 $ '''uname -n'''&lt;br /&gt;
 host&lt;br /&gt;
 $ '''echo $DISPLAY'''&lt;br /&gt;
 localhost:10.0&lt;br /&gt;
 $ '''/usr/openwin/bin/xauth extract - host/unix:10 | su - root -c &amp;quot;/usr/openwin/bin/xauth merge - ; DISPLAY=localhost:10.0 /usr/openwin/bin/xclock&amp;quot;'''&lt;br /&gt;
&lt;br /&gt;
''sudo'' example:&lt;br /&gt;
 $ '''uname -n'''&lt;br /&gt;
 host&lt;br /&gt;
 $ '''echo $DISPLAY'''&lt;br /&gt;
 localhost:10.0&lt;br /&gt;
 $ '''/usr/openwin/bin/xauth extract - host/unix:10 | sudo su - root -c &amp;quot;/usr/openwin/bin/xauth merge - ; DISPLAY=localhost:10.0 /usr/openwin/bin/xclock&amp;quot;'''&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.derkeiler.com/Mailing-Lists/securityfocus/Secure_Shell/2003-05/0001.html Re: X11 forwarding after su'ing]&lt;br /&gt;
* [http://www.sudo.ws/pipermail/sudo-users/2002-August/001156.html using sudo and ssh together`]&lt;/div&gt;</description>
			<pubDate>Mon, 12 Nov 2007 18:56:08 GMT</pubDate>			<dc:creator>Hutch</dc:creator>			<comments>http://brandonhutchinson.com/wiki/Talk:X11_Forwarding_and_su/sudo</comments>		</item>
	</channel>
</rss>