{"id":231,"date":"2020-05-26T17:05:09","date_gmt":"2020-05-26T15:05:09","guid":{"rendered":"https:\/\/camilomatajira.wordpress.com\/?p=231"},"modified":"2020-05-26T17:05:09","modified_gmt":"2020-05-26T15:05:09","slug":"python-ssh-debugger","status":"publish","type":"post","link":"https:\/\/camilo.matajira.com\/?p=231","title":{"rendered":"Python SSH Debugger"},"content":{"rendered":"\n<p>In my job as a Linux System Administrator, a considerable amount of the support requests that I receive are related to SSH problems.&nbsp;<\/p>\n\n\n\n<p>Given this, I created a Python script that checks the most common reasons the ssh-client might not be working correctly. It creates a report and allows the user to fix those problems by pressing a button.&nbsp;<\/p>\n\n\n\n<p>The idea is to create a tool that can do a diagnosis of the ssh-problems of a Linux user. In case of problems the tool will allow the person to fix the issues with one click.<\/p>\n\n\n\n<p>On top of that, I also wanted to practice:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Test-Driven Development in Python (see tests.py).<\/li><li>Experiment with Python System tools like os, stat, pathlib.<\/li><li>Test the connection between Python and Bash through the subprocess module.<\/li><li>Create a simple Tkinter GUI.<\/li><li>Write clean code using Bob Martin&#8217;s philosophy: self-documentary code, no commenting, etc.<\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">How to diagnose an ssh-key problem?<\/h2>\n\n\n\n<p>Client-side ssh problems are usually related to:&nbsp;<\/p>\n\n\n\n<p>1. Bad private ssh-key permissions: Keys should be 400, 600 or 700, nothing more.&nbsp;<\/p>\n\n\n\n<p>2. Problems with the user&#8217;s ssh folder permissions (\/home\/user\/.ssh\/): It should be 700.<\/p>\n\n\n\n<p>3. Problems with the user&#8217;s home folder permissions (\/home\/user): It should be 755.<\/p>\n\n\n\n<p>4. Problems with the home folder permissions (\/home\/): It should be 755.<\/p>\n\n\n\n<p>5. A problem in the content of an ssh key because someone manipulated (by mistake probably)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Gitlab<\/h2>\n\n\n\n<p>You can check and try the script <a href=\"https:\/\/gitlab.com\/ca.matajira966\/ssh_debugger\">here<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my job as a Linux System Administrator, a considerable amount of the support requests that I receive are related to SSH problems.&nbsp; Given this, I created a Python script that checks the most common reasons the ssh-client might not be working correctly. It creates a report and allows the user to fix those problems&#8230;<\/p>\n","protected":false},"author":2,"featured_media":236,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[22,43,49,51,55,63,65,66,68,71],"class_list":["post-231","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-projects","tag-clean-code","tag-linux","tag-os","tag-pathlib","tag-python","tag-ssh","tag-stat","tag-subprocess","tag-tdd","tag-tkinter"],"_links":{"self":[{"href":"https:\/\/camilo.matajira.com\/index.php?rest_route=\/wp\/v2\/posts\/231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/camilo.matajira.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/camilo.matajira.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/camilo.matajira.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/camilo.matajira.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=231"}],"version-history":[{"count":0,"href":"https:\/\/camilo.matajira.com\/index.php?rest_route=\/wp\/v2\/posts\/231\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/camilo.matajira.com\/index.php?rest_route=\/wp\/v2\/media\/236"}],"wp:attachment":[{"href":"https:\/\/camilo.matajira.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/camilo.matajira.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/camilo.matajira.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}