<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mike Gerwitz &#187; SSH</title>
	<atom:link href="http://mikegerwitz.com/tags/ssh/feed/" rel="self" type="application/rss+xml" />
	<link>http://mikegerwitz.com</link>
	<description>Free Software Hacker</description>
	<lastBuildDate>Tue, 22 May 2012 02:08:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>SSH public key still prompting for password</title>
		<link>http://mikegerwitz.com/ssh-public-key-still-prompting-for-password/</link>
		<comments>http://mikegerwitz.com/ssh-public-key-still-prompting-for-password/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 21:57:42 +0000</pubDate>
		<dc:creator>Mike Gerwitz</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://mikegerwitz.com/?p=401</guid>
		<description><![CDATA[This was one of those problems that irritated me considerably, since the solution was the last thing that I tried. The issue was that, I noticed, my private key for one of my users on one of my boxes was no longer being accepted. It was still prompting for the password. I tried regenerating the [...]]]></description>
			<content:encoded><![CDATA[<p>This was one of those problems that irritated me considerably, since the solution was the last thing that I tried. The issue was that, I noticed, my private key for one of my users on one of my boxes was no longer being accepted. It was still prompting for the password. I tried regenerating the key, clearing out <tt>~/.ssh/authorized_keys</tt>, reconfiguring ssh, reinstalling <acronym title="Secure Shell">SSH</acronym>&#8230;of course, the logical thing to do would have been to check the logs. But for whatever reason, I saved that for last.</p>
<p>When attempting to log into the server, I was prompted for a password as if the server did not have my public key. It certainly did. Checking <tt>/var/log/auth.log</tt>, I noticed this:</p>
<blockquote><p>
# /var/log/auth.log<br />
Nov  2 17:47:37 hostname sshd[2053]: Authentication refused: bad ownership or modes for directory /home/myuser
</p></blockquote>
<p>Somehow (likely due to user error), the permissions for <tt>/home/myuser</tt> was set to <tt>0777</tt>!</p>

<div class="wp_codebox"><table><tr id="p4014"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p401code4"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-lah</span> <span style="color: #000000; font-weight: bold;">/</span>home <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> myuser
drwxrwxrwx <span style="color: #000000;">119</span> myuser myuser 8.0K <span style="color: #000000;">2010</span>-<span style="color: #000000;">11</span>-02 <span style="color: #000000;">17</span>:<span style="color: #000000;">45</span> myuser</pre></td></tr></table></div>

<p>The solution was to restore the directory permissions to what they should be &#8211; r/w access for the owner only.</p>

<div class="wp_codebox"><table><tr id="p4015"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p401code5"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> 0755 ~myuser
$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-lah</span> <span style="color: #000000; font-weight: bold;">/</span>home <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> myuser
drwxr-xr-x <span style="color: #000000;">119</span> myuser myuser 8.0K <span style="color: #000000;">2010</span>-<span style="color: #000000;">11</span>-02 <span style="color: #000000;">17</span>:<span style="color: #000000;">45</span> myuser</pre></td></tr></table></div>

<p>Hopefully now you&#8217;ll be able to log in with your private key.</p>

<div class="wp_codebox"><table><tr id="p4016"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p401code6"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ssh</span> myhost
$ <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>auth.log
Nov  2 17:50:36 <span style="color: #c20cb9; font-weight: bold;">hostname</span> sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span>2212<span style="color: #7a0874; font-weight: bold;">&#93;</span>: Accepted publickey <span style="color: #000000; font-weight: bold;">for</span> myuser from 192.168.1.XXX port XXXXX ssh2</pre></td></tr></table></div>
]]></content:encoded>
			<wfw:commentRss>http://mikegerwitz.com/ssh-public-key-still-prompting-for-password/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ssh-copy-id and sshd port</title>
		<link>http://mikegerwitz.com/ssh-copy-id-and-sshd-port/</link>
		<comments>http://mikegerwitz.com/ssh-copy-id-and-sshd-port/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 03:21:57 +0000</pubDate>
		<dc:creator>Mike Gerwitz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://www.mikegerwitz.com/2009/10/07/ssh-copy-id-and-sshd-port/</guid>
		<description><![CDATA[For security purposes, I don&#8217;t run sshd on the default port (22). This gave me some problems when attempting to use the command ssh-copy-id. Ideally, you&#8217;d expect the following to work: 1 ssh-copy-id -p XXXX -i '~/.ssh/id_rsa.pub' username@host However, that didn&#8217;t do anything but output an error: Bad port 'umask 077; test -d .ssh &#124;&#124; [...]]]></description>
			<content:encoded><![CDATA[<p>For security purposes, I don&#8217;t run sshd on the default port (22). This gave me some problems when attempting to use the command <tt>ssh-copy-id</tt>. Ideally, you&#8217;d expect the following to work:</p>

<div class="wp_codebox"><table><tr id="p1208"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p120code8"><pre class="bash" style="font-family:monospace;">ssh-copy-id <span style="color: #660033;">-p</span> XXXX <span style="color: #660033;">-i</span> <span style="color: #ff0000;">'~/.ssh/id_rsa.pub'</span> username<span style="color: #000000; font-weight: bold;">@</span>host</pre></td></tr></table></div>

<p>However, that didn&#8217;t do anything but output an error:</p>
<p><tt>Bad port 'umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys'</tt></p>
<p>The solution was to enclose it in quotes as follows:</p>
<p>ssh-copy-id &#8216;-p XXXX -i ~/.ssh/id_rsa.pub username@host&#8217;</p>
<p>Hope that helps.</p>
<p>(The above error probably doesn&#8217;t make any sense. <tt>ssh-copy-id</tt> is a shell script. The command that appears in the error message is a command sent to the server via <acronym title="Secure Shell">SSH</acronym>. Feel free to take a look at the file: <tt>cat `locate ssh-copy-id | head -n1`</tt>)</p>]]></content:encoded>
			<wfw:commentRss>http://mikegerwitz.com/ssh-copy-id-and-sshd-port/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

