{"id":896,"date":"2010-07-14T12:34:45","date_gmt":"2010-07-14T10:34:45","guid":{"rendered":"http:\/\/raftaman.net\/?p=896"},"modified":"2021-05-15T11:46:40","modified_gmt":"2021-05-15T09:46:40","slug":"granting-access-to-x-server-with-xhost","status":"publish","type":"post","link":"https:\/\/possiblelossofprecision.net\/?p=896","title":{"rendered":"Granting access to X server with xhost"},"content":{"rendered":"<p>Every X server internally manages an ACL (Access Control List) of those hosts, that are allowed to connect. The server only authorizes connections from X clients, whose host is on that list and rejects access to all others. The xhost program is used to add or revert access to the X server for specified hosts. It&#8217;s also possible to specify a user and a hostname pair.<\/p>\n<h2>Host-based Control (xhost)<\/h2>\n<p>To see if access control is enabled, type <code>xhost<\/code>. It displays the current ACL:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ xhost\r\naccess control enabled, only authorized clients can connect\r\nSI:localuser:user\r\nSI:localuser:gdm\r\nSI:localuser:root\r\n<\/pre>\n<p>If the access control is disabled, it prints:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ xhost\r\naccess control disabled, clients can connect from any host\r\n<\/pre>\n<p>To disable the access control type <code>xhost +<\/code> which allows any host to access your X server. <strong>You probaly don&#8217;t want to do this<\/strong> because it allows the world to open windows on your screen and grab the keystrokes you type.<\/p>\n<p>To enable the access control again type <code>xhost -<\/code> and only authorized clients\/hosts are allowed to do the things mentioned above.<\/p>\n<h2>A simple example<\/h2>\n<p>Now let&#8217;s do something useful, e.g. grant another user on the local machine access to our X server. It&#8217;s pretty easy:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ xhost +SI:localuser:anotheruser\r\nlocaluser:anotheruser being added to access control list\r\n<\/pre>\n<p>And after that, <em>anotheruser<\/em> should show up in the ACL:<\/p>\n<pre class=\"brush: bash; highlight: [3]; title: ; notranslate\" title=\"\">\r\n$ xhost\r\naccess control disabled, clients can connect from any host\r\nSI:localuser:anotheruser\r\nSI:localuser:user\r\nSI:localuser:gdm\r\nSI:localuser:root\r\n<\/pre>\n<p>To revoke the access right for <em>anotheruser<\/em>, use<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ xhost -SI:localuser:anotheruser\r\nlocaluser:anotheruser being removed from access control list\r\n<\/pre>\n<p>For granting access to users on different hosts, have a look at the <a href=\"http:\/\/linux.die.net\/man\/1\/xhost\">xhost manpage<\/a> or the examples provided on <a href=\"http:\/\/linux.about.com\/library\/cmd\/blcmdl_xhost.htm\">http:\/\/linux.about.com\/library\/cmd\/blcmdl_xhost.htm<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Every X server internally manages an ACL (Access Control List) of those hosts, that are allowed to connect. The server only authorizes connections from X clients, whose host is on that list and rejects access to all others. The xhost program is used to add or revert access to the X server for specified hosts. It&#8217;s also possible to specify&#8230; <a href=\"https:\/\/possiblelossofprecision.net\/?p=896\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[13,7,14],"class_list":["post-896","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-centos","tag-fedora","tag-x"],"_links":{"self":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/896","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=896"}],"version-history":[{"count":10,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/896\/revisions"}],"predecessor-version":[{"id":2681,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/896\/revisions\/2681"}],"wp:attachment":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}