pyssh2age 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.
@@ -0,0 +1,7 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ /build/
4
+ /dist/
5
+ *.egg-info/
6
+ .venv/
7
+ .pytest_cache/
@@ -0,0 +1,24 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ivan Krasilnikov (Python port)
4
+ Copyright (c) 2022 Jörg Thalheim (ssh-to-age)
5
+ Copyright (c) 2019 Google LLC (bech32)
6
+ Copyright (c) 2017 Takatoshi Nakagawa (bech32)
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
@@ -0,0 +1,117 @@
1
+ Metadata-Version: 2.5
2
+ Name: pyssh2age
3
+ Version: 1.0.0
4
+ Summary: Convert SSH Ed25519 keys to age keys (pure-Python port of ssh-to-age)
5
+ Project-URL: Homepage, https://github.com/ivankra/pyssh2age
6
+ Project-URL: Source, https://github.com/ivankra/pyssh2age
7
+ Project-URL: Issues, https://github.com/ivankra/pyssh2age/issues
8
+ Author: Ivan Krasilnikov
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: age,ed25519,sops,sops-nix,ssh,x25519
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: System Administrators
15
+ Classifier: Operating System :: MacOS
16
+ Classifier: Operating System :: Microsoft :: Windows
17
+ Classifier: Operating System :: POSIX
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Topic :: Security :: Cryptography
21
+ Classifier: Topic :: Utilities
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+
25
+ # pyssh2age
26
+
27
+ Convert SSH Ed25519 keys to [age](https://github.com/FiloSottile/age) keys,
28
+ e.g. for [sops](https://github.com/getsops/sops) or [sops-nix](https://github.com/Mic92/sops-nix).
29
+
30
+ A single-file pure-Python port of [ssh-to-age](https://github.com/Mic92/ssh-to-age) that produces the same keys.
31
+ Python 3.9+, using only the standard library and `ssh-keygen` to decrypt passphrase-protected keys.
32
+
33
+ The conversion is the standard Ed25519 → X25519 mapping
34
+ ([explained here](https://blog.filippo.io/using-ed25519-keys-for-encryption/)):
35
+ the age secret is `sha512(seed)[:32]`, and the age public key is the Montgomery
36
+ u-coordinate of the Ed25519 public point, `u = (1 + y) / (1 - y)`.
37
+
38
+ ## Install
39
+
40
+ ```console
41
+ $ pipx install pyssh2age # or: uv tool install pyssh2age
42
+ ```
43
+
44
+ This installs the `pyssh2age` command and `ssh-to-age` alias.
45
+ Or copy [`src/pyssh2age.py`](https://github.com/ivankra/pyssh2age/blob/main/src/pyssh2age.py) anywhere and run it.
46
+
47
+ ## Usage
48
+
49
+ ```console
50
+ $ cat ~/.ssh/id_ed25519.pub | pyssh2age
51
+ age17044m9u...
52
+
53
+ $ pyssh2age -i ~/.ssh/id_ed25519.pub
54
+ age17044m9u...
55
+
56
+ $ ssh-keyscan host1 host2 | pyssh2age # or authorized_keys, known_hosts
57
+ skipped key: got ssh-rsa key type, but only ed25519 keys are supported
58
+ age1hjm3au...
59
+ age1v8zjc4...
60
+
61
+ $ pyssh2age --private-key -i ~/.ssh/id_ed25519 -o key.txt # see Security below
62
+ ```
63
+
64
+ Decrypting passphrase-protected private keys needs a Unix-like system;
65
+ everything else also works on Windows.
66
+
67
+ For a passphrase-protected key you're prompted on the terminal. In scripts,
68
+ use `--stdinpass` or `SSH_TO_AGE_PASSPHRASE`:
69
+
70
+ ```console
71
+ $ systemd-ask-password | pyssh2age --private-key --stdinpass -i ~/.ssh/id_ed25519 -o key.txt
72
+ ```
73
+
74
+ The age identity file (`-o`) is created with mode 0600, atomically replacing
75
+ any existing file. As in the Go version, options work with one or two dashes.
76
+
77
+ ## Library
78
+
79
+ ```python
80
+ import pyssh2age
81
+
82
+ pyssh2age.ssh_public_key_to_age("ssh-ed25519 AAAA... me@host") # "age1..."
83
+ pyssh2age.ssh_public_keys_to_age(open("authorized_keys").read()) # ["age1...", ...]
84
+
85
+ key = open("id_ed25519").read()
86
+ try:
87
+ identity = pyssh2age.ssh_private_key_to_age(key) # "AGE-SECRET-KEY-1..."
88
+ except pyssh2age.PassphraseRequired:
89
+ identity = pyssh2age.ssh_private_key_to_age(key, passphrase="...")
90
+ ```
91
+
92
+ Failures raise `ConvertError`; non-Ed25519 keys raise its subclass
93
+ `UnsupportedKeyType`. Lower-level helpers: `ed25519_public_to_x25519`,
94
+ `ed25519_seed_to_x25519`, `x25519_public`, `age_recipient`, `age_identity`.
95
+
96
+ ## Security
97
+
98
+ - **The age key is as powerful as the SSH key.** The original `id_ed25519` file you
99
+ derived it from can't be recovered, but it *is* the Ed25519 signing scalar:
100
+ whoever has it can sign as the SSH key and log in wherever that key is authorized.
101
+ - **Output file is written unencrypted** (as in the Go version),
102
+ even if the SSH key has a passphrase. Encrypt it with:
103
+ `pyssh2age --private-key ... | age -p -o key.txt.age`.
104
+
105
+ ## Development
106
+
107
+ The tests need `ssh-keygen` and `openssl`, and also check results with `age`
108
+ if it's installed:
109
+
110
+ ```console
111
+ $ python3 tests/test_pyssh2age.py
112
+ $ GO_SSH_TO_AGE=/path/to/ssh-to-age python3 tests/test_pyssh2age.py # also compare with the Go version
113
+ ```
114
+
115
+ ## License
116
+
117
+ MIT. Based on [ssh-to-age](https://github.com/Mic92/ssh-to-age) by Jörg Thalheim.
@@ -0,0 +1,93 @@
1
+ # pyssh2age
2
+
3
+ Convert SSH Ed25519 keys to [age](https://github.com/FiloSottile/age) keys,
4
+ e.g. for [sops](https://github.com/getsops/sops) or [sops-nix](https://github.com/Mic92/sops-nix).
5
+
6
+ A single-file pure-Python port of [ssh-to-age](https://github.com/Mic92/ssh-to-age) that produces the same keys.
7
+ Python 3.9+, using only the standard library and `ssh-keygen` to decrypt passphrase-protected keys.
8
+
9
+ The conversion is the standard Ed25519 → X25519 mapping
10
+ ([explained here](https://blog.filippo.io/using-ed25519-keys-for-encryption/)):
11
+ the age secret is `sha512(seed)[:32]`, and the age public key is the Montgomery
12
+ u-coordinate of the Ed25519 public point, `u = (1 + y) / (1 - y)`.
13
+
14
+ ## Install
15
+
16
+ ```console
17
+ $ pipx install pyssh2age # or: uv tool install pyssh2age
18
+ ```
19
+
20
+ This installs the `pyssh2age` command and `ssh-to-age` alias.
21
+ Or copy [`src/pyssh2age.py`](https://github.com/ivankra/pyssh2age/blob/main/src/pyssh2age.py) anywhere and run it.
22
+
23
+ ## Usage
24
+
25
+ ```console
26
+ $ cat ~/.ssh/id_ed25519.pub | pyssh2age
27
+ age17044m9u...
28
+
29
+ $ pyssh2age -i ~/.ssh/id_ed25519.pub
30
+ age17044m9u...
31
+
32
+ $ ssh-keyscan host1 host2 | pyssh2age # or authorized_keys, known_hosts
33
+ skipped key: got ssh-rsa key type, but only ed25519 keys are supported
34
+ age1hjm3au...
35
+ age1v8zjc4...
36
+
37
+ $ pyssh2age --private-key -i ~/.ssh/id_ed25519 -o key.txt # see Security below
38
+ ```
39
+
40
+ Decrypting passphrase-protected private keys needs a Unix-like system;
41
+ everything else also works on Windows.
42
+
43
+ For a passphrase-protected key you're prompted on the terminal. In scripts,
44
+ use `--stdinpass` or `SSH_TO_AGE_PASSPHRASE`:
45
+
46
+ ```console
47
+ $ systemd-ask-password | pyssh2age --private-key --stdinpass -i ~/.ssh/id_ed25519 -o key.txt
48
+ ```
49
+
50
+ The age identity file (`-o`) is created with mode 0600, atomically replacing
51
+ any existing file. As in the Go version, options work with one or two dashes.
52
+
53
+ ## Library
54
+
55
+ ```python
56
+ import pyssh2age
57
+
58
+ pyssh2age.ssh_public_key_to_age("ssh-ed25519 AAAA... me@host") # "age1..."
59
+ pyssh2age.ssh_public_keys_to_age(open("authorized_keys").read()) # ["age1...", ...]
60
+
61
+ key = open("id_ed25519").read()
62
+ try:
63
+ identity = pyssh2age.ssh_private_key_to_age(key) # "AGE-SECRET-KEY-1..."
64
+ except pyssh2age.PassphraseRequired:
65
+ identity = pyssh2age.ssh_private_key_to_age(key, passphrase="...")
66
+ ```
67
+
68
+ Failures raise `ConvertError`; non-Ed25519 keys raise its subclass
69
+ `UnsupportedKeyType`. Lower-level helpers: `ed25519_public_to_x25519`,
70
+ `ed25519_seed_to_x25519`, `x25519_public`, `age_recipient`, `age_identity`.
71
+
72
+ ## Security
73
+
74
+ - **The age key is as powerful as the SSH key.** The original `id_ed25519` file you
75
+ derived it from can't be recovered, but it *is* the Ed25519 signing scalar:
76
+ whoever has it can sign as the SSH key and log in wherever that key is authorized.
77
+ - **Output file is written unencrypted** (as in the Go version),
78
+ even if the SSH key has a passphrase. Encrypt it with:
79
+ `pyssh2age --private-key ... | age -p -o key.txt.age`.
80
+
81
+ ## Development
82
+
83
+ The tests need `ssh-keygen` and `openssl`, and also check results with `age`
84
+ if it's installed:
85
+
86
+ ```console
87
+ $ python3 tests/test_pyssh2age.py
88
+ $ GO_SSH_TO_AGE=/path/to/ssh-to-age python3 tests/test_pyssh2age.py # also compare with the Go version
89
+ ```
90
+
91
+ ## License
92
+
93
+ MIT. Based on [ssh-to-age](https://github.com/Mic92/ssh-to-age) by Jörg Thalheim.
@@ -0,0 +1,46 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "pyssh2age"
7
+ dynamic = ["version"]
8
+ description = "Convert SSH Ed25519 keys to age keys (pure-Python port of ssh-to-age)"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.9"
13
+ authors = [{ name = "Ivan Krasilnikov" }]
14
+ keywords = ["age", "ssh", "ed25519", "x25519", "sops", "sops-nix"]
15
+ classifiers = [
16
+ "Development Status :: 5 - Production/Stable",
17
+ "Environment :: Console",
18
+ "Intended Audience :: System Administrators",
19
+ "Operating System :: POSIX",
20
+ "Operating System :: MacOS",
21
+ "Operating System :: Microsoft :: Windows",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3 :: Only",
24
+ "Topic :: Security :: Cryptography",
25
+ "Topic :: Utilities",
26
+ ]
27
+ dependencies = []
28
+
29
+ [project.urls]
30
+ Homepage = "https://github.com/ivankra/pyssh2age"
31
+ Source = "https://github.com/ivankra/pyssh2age"
32
+ Issues = "https://github.com/ivankra/pyssh2age/issues"
33
+
34
+ [project.scripts]
35
+ pyssh2age = "pyssh2age:main"
36
+ ssh-to-age = "pyssh2age:main" # alias for users of the Go version
37
+
38
+ [tool.hatch.version]
39
+ path = "src/pyssh2age.py"
40
+
41
+ [tool.hatch.build.targets.wheel] # a single module: src/pyssh2age.py
42
+ only-include = ["src/pyssh2age.py"]
43
+ sources = ["src"]
44
+
45
+ [tool.hatch.build.targets.sdist]
46
+ include = ["src", "tests", "README.md", "LICENSE"]