In my job as a Linux System Administrator, a considerable amount of the support requests that I receive are related to SSH problems.
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.
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.
On top of that, I also wanted to practice:
- Test-Driven Development in Python (see tests.py).
- Experiment with Python System tools like os, stat, pathlib.
- Test the connection between Python and Bash through the subprocess module.
- Create a simple Tkinter GUI.
- Write clean code using Bob Martin’s philosophy: self-documentary code, no commenting, etc.
How to diagnose an ssh-key problem?
Client-side ssh problems are usually related to:
1. Bad private ssh-key permissions: Keys should be 400, 600 or 700, nothing more.
2. Problems with the user’s ssh folder permissions (/home/user/.ssh/): It should be 700.
3. Problems with the user’s home folder permissions (/home/user): It should be 755.
4. Problems with the home folder permissions (/home/): It should be 755.
5. A problem in the content of an ssh key because someone manipulated (by mistake probably)
Gitlab
You can check and try the script here