dargslan-sshkey-audit 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dargslan_sshkey_audit-1.0.0/LICENSE +18 -0
- dargslan_sshkey_audit-1.0.0/PKG-INFO +51 -0
- dargslan_sshkey_audit-1.0.0/README.md +29 -0
- dargslan_sshkey_audit-1.0.0/dargslan_sshkey_audit/__init__.py +5 -0
- dargslan_sshkey_audit-1.0.0/dargslan_sshkey_audit/main.py +59 -0
- dargslan_sshkey_audit-1.0.0/dargslan_sshkey_audit.egg-info/PKG-INFO +51 -0
- dargslan_sshkey_audit-1.0.0/dargslan_sshkey_audit.egg-info/SOURCES.txt +10 -0
- dargslan_sshkey_audit-1.0.0/dargslan_sshkey_audit.egg-info/dependency_links.txt +1 -0
- dargslan_sshkey_audit-1.0.0/dargslan_sshkey_audit.egg-info/entry_points.txt +2 -0
- dargslan_sshkey_audit-1.0.0/dargslan_sshkey_audit.egg-info/top_level.txt +1 -0
- dargslan_sshkey_audit-1.0.0/pyproject.toml +31 -0
- dargslan_sshkey_audit-1.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Dargslan (https://dargslan.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
18
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dargslan-sshkey-audit
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: SSH key auditor — scan authorized_keys, detect weak keys, expiry, unused keys
|
|
5
|
+
Author-email: Dargslan <info@dargslan.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://dargslan.com
|
|
8
|
+
Project-URL: Documentation, https://dargslan.com/blog
|
|
9
|
+
Project-URL: Free Cheat Sheets, https://dargslan.com/cheat-sheets
|
|
10
|
+
Project-URL: Linux & DevOps Books, https://dargslan.com/books
|
|
11
|
+
Keywords: linux,ssh,key,audit,security,authorized-keys,sysadmin
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: System Administrators
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Topic :: System :: Systems Administration
|
|
18
|
+
Requires-Python: >=3.7
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# dargslan-sshkey-audit
|
|
24
|
+
|
|
25
|
+
SSH key auditor — scan authorized_keys, detect weak keys, expiry, unused keys
|
|
26
|
+
|
|
27
|
+
Part of the [Dargslan Linux Toolkit](https://pypi.org/project/dargslan-toolkit/) — 100 CLI tools for Linux sysadmins.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install dargslan-sshkey-audit
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
dargslan-sshkey-audit
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## More Resources
|
|
42
|
+
|
|
43
|
+
- [Linux eBooks](https://dargslan.com/books) — 210+ professional eBooks
|
|
44
|
+
- [Free Cheat Sheets](https://dargslan.com/cheat-sheets)
|
|
45
|
+
- [Blog](https://dargslan.com/blog)
|
|
46
|
+
- [dargslan-toolkit](https://pypi.org/project/dargslan-toolkit/) — Install all 100 tools at once
|
|
47
|
+
|
|
48
|
+
## License
|
|
49
|
+
|
|
50
|
+
MIT — [Dargslan](https://dargslan.com)
|
|
51
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# dargslan-sshkey-audit
|
|
2
|
+
|
|
3
|
+
SSH key auditor — scan authorized_keys, detect weak keys, expiry, unused keys
|
|
4
|
+
|
|
5
|
+
Part of the [Dargslan Linux Toolkit](https://pypi.org/project/dargslan-toolkit/) — 100 CLI tools for Linux sysadmins.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install dargslan-sshkey-audit
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
dargslan-sshkey-audit
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## More Resources
|
|
20
|
+
|
|
21
|
+
- [Linux eBooks](https://dargslan.com/books) — 210+ professional eBooks
|
|
22
|
+
- [Free Cheat Sheets](https://dargslan.com/cheat-sheets)
|
|
23
|
+
- [Blog](https://dargslan.com/blog)
|
|
24
|
+
- [dargslan-toolkit](https://pypi.org/project/dargslan-toolkit/) — Install all 100 tools at once
|
|
25
|
+
|
|
26
|
+
## License
|
|
27
|
+
|
|
28
|
+
MIT — [Dargslan](https://dargslan.com)
|
|
29
|
+
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import os, subprocess, sys, datetime
|
|
2
|
+
|
|
3
|
+
def get_ssh_keys():
|
|
4
|
+
keys = []
|
|
5
|
+
for user_dir in ['/root'] + [f'/home/{u}' for u in os.listdir('/home')] if os.path.isdir('/home') else ['/root']:
|
|
6
|
+
ak = os.path.join(user_dir, '.ssh', 'authorized_keys')
|
|
7
|
+
if os.path.isfile(ak):
|
|
8
|
+
try:
|
|
9
|
+
with open(ak) as f:
|
|
10
|
+
for line in f:
|
|
11
|
+
line = line.strip()
|
|
12
|
+
if line and not line.startswith('#'):
|
|
13
|
+
keys.append({'user': os.path.basename(user_dir) if user_dir != '/root' else 'root', 'key': line, 'file': ak})
|
|
14
|
+
except PermissionError:
|
|
15
|
+
keys.append({'user': os.path.basename(user_dir), 'key': '[permission denied]', 'file': ak})
|
|
16
|
+
return keys
|
|
17
|
+
|
|
18
|
+
def check_key_types(keys):
|
|
19
|
+
weak = []
|
|
20
|
+
for k in keys:
|
|
21
|
+
parts = k['key'].split()
|
|
22
|
+
if len(parts) >= 2:
|
|
23
|
+
ktype = parts[0]
|
|
24
|
+
if ktype in ('ssh-dss', 'ssh-dsa'):
|
|
25
|
+
weak.append(f" WEAK: {k['user']} uses DSA key (deprecated)")
|
|
26
|
+
elif ktype == 'ssh-rsa':
|
|
27
|
+
weak.append(f" INFO: {k['user']} uses RSA key (consider ed25519)")
|
|
28
|
+
return weak
|
|
29
|
+
|
|
30
|
+
def main():
|
|
31
|
+
print("=== SSH Key Audit ===")
|
|
32
|
+
print()
|
|
33
|
+
keys = get_ssh_keys()
|
|
34
|
+
if not keys:
|
|
35
|
+
print("No authorized_keys found")
|
|
36
|
+
return
|
|
37
|
+
print(f"Found {len(keys)} authorized key(s):")
|
|
38
|
+
for k in keys:
|
|
39
|
+
parts = k['key'].split()
|
|
40
|
+
ktype = parts[0] if parts else 'unknown'
|
|
41
|
+
comment = parts[-1] if len(parts) >= 3 else 'no-comment'
|
|
42
|
+
print(f" User: {k['user']} Type: {ktype} Comment: {comment}")
|
|
43
|
+
print()
|
|
44
|
+
weak = check_key_types(keys)
|
|
45
|
+
if weak:
|
|
46
|
+
print("Key Analysis:")
|
|
47
|
+
for w in weak:
|
|
48
|
+
print(w)
|
|
49
|
+
else:
|
|
50
|
+
print("All keys use strong algorithms")
|
|
51
|
+
host_keys = [f for f in os.listdir('/etc/ssh') if f.startswith('ssh_host_') and f.endswith('.pub')] if os.path.isdir('/etc/ssh') else []
|
|
52
|
+
if host_keys:
|
|
53
|
+
print(f"\nHost keys: {len(host_keys)}")
|
|
54
|
+
for hk in host_keys:
|
|
55
|
+
print(f" {hk}")
|
|
56
|
+
|
|
57
|
+
if __name__ == "__main__":
|
|
58
|
+
main()
|
|
59
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dargslan-sshkey-audit
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: SSH key auditor — scan authorized_keys, detect weak keys, expiry, unused keys
|
|
5
|
+
Author-email: Dargslan <info@dargslan.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://dargslan.com
|
|
8
|
+
Project-URL: Documentation, https://dargslan.com/blog
|
|
9
|
+
Project-URL: Free Cheat Sheets, https://dargslan.com/cheat-sheets
|
|
10
|
+
Project-URL: Linux & DevOps Books, https://dargslan.com/books
|
|
11
|
+
Keywords: linux,ssh,key,audit,security,authorized-keys,sysadmin
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: System Administrators
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Topic :: System :: Systems Administration
|
|
18
|
+
Requires-Python: >=3.7
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# dargslan-sshkey-audit
|
|
24
|
+
|
|
25
|
+
SSH key auditor — scan authorized_keys, detect weak keys, expiry, unused keys
|
|
26
|
+
|
|
27
|
+
Part of the [Dargslan Linux Toolkit](https://pypi.org/project/dargslan-toolkit/) — 100 CLI tools for Linux sysadmins.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install dargslan-sshkey-audit
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
dargslan-sshkey-audit
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## More Resources
|
|
42
|
+
|
|
43
|
+
- [Linux eBooks](https://dargslan.com/books) — 210+ professional eBooks
|
|
44
|
+
- [Free Cheat Sheets](https://dargslan.com/cheat-sheets)
|
|
45
|
+
- [Blog](https://dargslan.com/blog)
|
|
46
|
+
- [dargslan-toolkit](https://pypi.org/project/dargslan-toolkit/) — Install all 100 tools at once
|
|
47
|
+
|
|
48
|
+
## License
|
|
49
|
+
|
|
50
|
+
MIT — [Dargslan](https://dargslan.com)
|
|
51
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
dargslan_sshkey_audit/__init__.py
|
|
5
|
+
dargslan_sshkey_audit/main.py
|
|
6
|
+
dargslan_sshkey_audit.egg-info/PKG-INFO
|
|
7
|
+
dargslan_sshkey_audit.egg-info/SOURCES.txt
|
|
8
|
+
dargslan_sshkey_audit.egg-info/dependency_links.txt
|
|
9
|
+
dargslan_sshkey_audit.egg-info/entry_points.txt
|
|
10
|
+
dargslan_sshkey_audit.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dargslan_sshkey_audit
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "dargslan-sshkey-audit"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "SSH key auditor — scan authorized_keys, detect weak keys, expiry, unused keys"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
requires-python = ">=3.7"
|
|
12
|
+
authors = [{name = "Dargslan", email = "info@dargslan.com"}]
|
|
13
|
+
keywords = ["linux", "ssh", "key", "audit", "security", "authorized-keys", "sysadmin"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 5 - Production/Stable",
|
|
16
|
+
"Intended Audience :: System Administrators",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Operating System :: POSIX :: Linux",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Topic :: System :: Systems Administration",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "https://dargslan.com"
|
|
25
|
+
Documentation = "https://dargslan.com/blog"
|
|
26
|
+
"Free Cheat Sheets" = "https://dargslan.com/cheat-sheets"
|
|
27
|
+
"Linux & DevOps Books" = "https://dargslan.com/books"
|
|
28
|
+
|
|
29
|
+
[project.scripts]
|
|
30
|
+
dargslan-sshkey-audit = "dargslan_sshkey_audit.main:main"
|
|
31
|
+
|