{"id":656,"date":"2019-01-10T14:36:09","date_gmt":"2019-01-10T09:06:09","guid":{"rendered":"http:\/\/www.cyberaka.com\/?p=656"},"modified":"2019-01-10T15:12:45","modified_gmt":"2019-01-10T09:42:45","slug":"ssh_exchange_identification-read-connection-reset-by-peer","status":"publish","type":"post","link":"https:\/\/www.cyberaka.com\/?p=656","title":{"rendered":"ssh_exchange_identification: read: Connection reset by peer"},"content":{"rendered":"\n<p>I recently upgraded my Mac Desktop and I noticed a strange problem that I was not able to SSH into my desktop from my laptop. I ultimately found out that the SSH setup that came with MacOS was having some issue as when I did ssh user@localhost on the desktop I got the same error:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ssh_exchange_identification: read: Connection reset by peer<\/pre>\n\n\n\n<p>I ended up tailing the system log using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo tail -f \/var\/log\/system.log<\/pre>\n\n\n\n<p>I observed the following entries in the log whenever a SSH was attempted.&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">com.apple.xpc.launchd[1] (com.openssh.sshd.[UUID][NUM]): Service exited with abnormal code: 1<\/pre>\n\n\n\n<p>It was clear that there was setup issue with the SSH that came with default MacOS installation. So I decided to spawn a separate SSH instance and watch it&#8217;s log:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo \/usr\/sbin\/sshd -d -p 2222<\/pre>\n\n\n\n<p>This command showed up a lot of issues related to file permissions.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Permissions 0644 for '\/etc\/ssh\/ssh_host_dsa_key' are too open.<br>Permissions 0644 for '\/etc\/ssh\/ssh_host_ecdsa_key' are too open.<br>Permissions 0644 for '\/etc\/ssh\/ssh_host_ed25519_key' are too open.<\/pre>\n\n\n\n<p>I fixed these permission issues by changing their permission to 400:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo chmod 400 \/etc\/ssh\/ssh_host_dsa_key<br>sudo chmod 400 \/etc\/ssh\/ssh_host_ecdsa_key<br>sudo chmod 400 \/etc\/ssh\/ssh_host_ed25519_key<\/pre>\n\n\n\n<p>After this change the following command succeeded and I was able to do successful SSH connection to port 2222.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo \/usr\/sbin\/sshd -d -p 2222<\/pre>\n\n\n\n<p>So I killed this process and decided to restart SSH:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo launchctl unload \/System\/Library\/LaunchDaemons\/ssh.plist&nbsp;<br>sudo lsof -i:22<br>echo $?<br>sudo launchctl load \/System\/Library\/LaunchDaemons\/ssh.plist&nbsp;<\/pre>\n\n\n\n<p>Once SSHD was restarted I could successfully do logins using ssh user@localhost from Desktop as well as remote login via SSH from my laptop.&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently upgraded my Mac Desktop and I noticed a strange problem that I was not able to SSH into my desktop from my laptop. I ultimately found out that the SSH setup that came with MacOS was having some issue as when I did ssh user@localhost on the desktop I got the same error: [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35,24],"tags":[],"class_list":["post-656","post","type-post","status-publish","format-standard","hentry","category-mac-os","category-tips-and-tricks"],"_links":{"self":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/656","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=656"}],"version-history":[{"count":4,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/656\/revisions"}],"predecessor-version":[{"id":660,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/656\/revisions\/660"}],"wp:attachment":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=656"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=656"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=656"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}