ssh-keyup 1.1.1__tar.gz → 1.3.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,202 @@
1
+ Metadata-Version: 2.4
2
+ Name: ssh-keyup
3
+ Version: 1.3.0
4
+ Summary: Passwordless SSH setup and ssh-copy-id alternative for any Linux or RouterOS device, such as Raspberry Pi, NVIDIA Jetson or MikroTik routers
5
+ Home-page: https://github.com/Kurokesu/ssh-keyup
6
+ Author: UAB Kurokesu
7
+ License: GPL-3.0-or-later
8
+ Project-URL: Repository, https://github.com/Kurokesu/ssh-keyup
9
+ Project-URL: Issues, https://github.com/Kurokesu/ssh-keyup/issues
10
+ Project-URL: Changelog, https://github.com/Kurokesu/ssh-keyup/releases
11
+ Keywords: ssh,ssh-keys,ssh-config,ssh-copy-id,passwordless-ssh,openssh,ed25519,raspberry-pi,rpi,jetson,mikrotik,routeros,iot,automation,vscode,remote-ssh,windows,linux
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: System Administrators
16
+ Classifier: Operating System :: Microsoft :: Windows
17
+ Classifier: Operating System :: POSIX :: Linux
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Topic :: System :: Networking
20
+ Classifier: Topic :: System :: Systems Administration
21
+ Classifier: Topic :: Utilities
22
+ Requires-Python: >=3.8
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Dynamic: license-file
26
+
27
+ # ssh-keyup
28
+
29
+ ![CI](https://github.com/Kurokesu/ssh-keyup/actions/workflows/ci.yml/badge.svg)
30
+ ![PyPI](https://img.shields.io/pypi/v/ssh-keyup)
31
+ ![Python](https://img.shields.io/badge/python-3.8%2B-brightgreen)
32
+ ![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux-blue)
33
+
34
+ **Set up passwordless SSH in one command on any Linux or RouterOS device, such as Raspberry Pi, NVIDIA Jetson or MikroTik routers.**
35
+
36
+ Tired of juggling `ssh-keygen`, `ssh-copy-id` (missing on Windows) and `~/.ssh/config` edits every time you set up a new device?
37
+
38
+ **`ssh-keyup`** handles all three in one interactive session.
39
+
40
+ ![One ssh-keyup session setting up a Raspberry Pi, then ssh to mypi alias logging in with no password.](https://raw.githubusercontent.com/Kurokesu/ssh-keyup/main/docs/demo.gif)
41
+
42
+ ## Quickstart
43
+
44
+ Install globally with pip:
45
+
46
+ ```bash
47
+ pip install ssh-keyup
48
+
49
+ ssh-keyup # ready to use anywhere
50
+ ```
51
+
52
+ > **Tip:** If `ssh-keyup` is missing or runs an old version after install, new script sits in a folder outside PATH (pip warns about this). Add that folder to PATH, or install with [pipx](https://pipx.pypa.io/) instead:
53
+ >
54
+ > `pipx install ssh-keyup`
55
+
56
+ Or run directly without installing:
57
+
58
+ ```bash
59
+ git clone https://github.com/Kurokesu/ssh-keyup.git
60
+ cd ssh-keyup
61
+ python ssh_keyup.py # Windows
62
+ python3 ssh_keyup.py # Linux
63
+ ```
64
+
65
+ Follow prompts, enter remote password once and you're done. Alias now works in anything that reads `~/.ssh/config`:
66
+
67
+ **Terminal:**
68
+
69
+ ```bash
70
+ ssh mypi # no password, ever again
71
+ ```
72
+
73
+ **VSCode:** [Remote - SSH](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh) works out of the box. Press `Ctrl+Shift+P`, select **Remote-SSH: Connect to Host** and pick your alias for a full IDE on the device, no password:
74
+
75
+ ![VSCode connecting to the mypi alias over Remote SSH without a password.](https://raw.githubusercontent.com/Kurokesu/ssh-keyup/main/docs/demo-vscode.gif)
76
+
77
+ ## Usage
78
+
79
+ ### Skip prompts
80
+
81
+ ```bash
82
+ ssh-keyup pi@192.168.1.23 mypi # user, host and alias in one go
83
+ ssh-keyup pi@192.168.1.23:2222 mypi # non-default SSH port
84
+ ssh-keyup admin@192.168.88.1 router # RouterOS, detected automatically
85
+ ```
86
+
87
+ Flags (`--host`, `--user`, `--alias`, `--port`, `--os`) work too, see `ssh-keyup --help`
88
+
89
+ ### Set up a fleet
90
+
91
+ ```bash
92
+ for host in 192.168.1.10 192.168.1.11 192.168.1.12; do
93
+ ssh-keyup pi@$host
94
+ done
95
+ ```
96
+
97
+ ### Manage entries
98
+
99
+ List or remove entries ssh-keyup manages:
100
+
101
+ ```bash
102
+ ssh-keyup --list
103
+ ssh-keyup --remove mypi # deletes its key pair too
104
+ ```
105
+
106
+ ## Prerequisites
107
+
108
+ **Python 3.8+** and OpenSSH tools (`ssh`, `ssh-keygen`) in PATH.
109
+
110
+ - **Windows 10/11**: Python from [python.org](https://www.python.org/downloads/) or Microsoft Store. OpenSSH Client via Settings > Optional Features or [Git for Windows](https://gitforwindows.org).
111
+ - **Linux**: `sudo apt install python3 openssh-client` (usually pre-installed).
112
+
113
+ ## How it works
114
+
115
+ ```mermaid
116
+ flowchart LR
117
+ run["ssh-keyup"] --> check["check connection"]
118
+ check --> gen["generate ed25519 key<br/>~/.ssh/id_ed25519_mypi"]
119
+ gen --> deploy["deploy public key<br/>~/.ssh/authorized_keys<br/>or /user/ssh-keys on RouterOS"]
120
+ deploy --> config["update ssh config<br/>~/.ssh/config"]
121
+ ```
122
+
123
+ ## Features
124
+
125
+ - Works on **Windows OpenSSH**, where `ssh-copy-id` does not exist
126
+ - **Never touches your password**. Only the public key is piped over SSH and OpenSSH prompts for the password itself
127
+ - One **Ed25519** key per device (`~/.ssh/id_ed25519_<alias>`), not one key reused everywhere
128
+ - Deploys in a **single SSH session**, one password prompt total
129
+ - Adds a named entry to `~/.ssh/config`, works instantly with `ssh <alias>` and VSCode Remote SSH
130
+ - Checks host is **reachable** first, so typos surface before keys exist
131
+ - Detects **RouterOS** and imports the key its way
132
+ - Recovers from **host key mismatches** after a reflash
133
+ - **Entry management**, list or retire devices without leaving stale keys behind
134
+ - **Zero dependencies**, standard library plus system OpenSSH
135
+
136
+ ## FAQ
137
+
138
+ ### Why not do it by hand?
139
+
140
+ Usual commands for passwordless SSH from Windows:
141
+
142
+ ```powershell
143
+ ssh-keygen -t ed25519
144
+ type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh pi@raspberrypi.local "cat >> ~/.ssh/authorized_keys"
145
+ notepad $env:USERPROFILE\.ssh\config # then add a Host block by hand
146
+ ```
147
+
148
+ Works once. Same key lands on every device, `~/.ssh` keeps default permissions that sshd may reject and each new device means another config edit.
149
+
150
+ ### Why not ssh-copy-id?
151
+
152
+ `ssh-copy-id` appends a key to `authorized_keys` and stops there. Windows OpenSSH does not ship it at all and RouterOS has no `authorized_keys` to append to.
153
+
154
+ | | ssh-keyup | ssh-copy-id |
155
+ |---|:---:|:---:|
156
+ | Works on Windows OpenSSH | yes | no |
157
+ | Works with RouterOS | yes | no |
158
+ | Ed25519 key per device | yes | no |
159
+ | Sets `authorized_keys` permissions | yes | yes |
160
+ | Writes `~/.ssh/config` alias | yes | no |
161
+ | Recovers from changed host key | yes | no |
162
+ | Entry management | yes | no |
163
+
164
+ ### How do I fix "REMOTE HOST IDENTIFICATION HAS CHANGED"?
165
+
166
+ Reflashing creates a new host key, so next `ssh` refuses to connect:
167
+
168
+ ```text
169
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
170
+ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
171
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
172
+ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
173
+ ...
174
+ Offending ECDSA key in ~/.ssh/known_hosts:3
175
+ Host key verification failed.
176
+ ```
177
+
178
+ Run `ssh-keyup` again. It detects a changed key, shows new fingerprint for confirmation, clears stale `known_hosts` entry with `ssh-keygen -R` and redeploys. Usually a reflash is behind it, but this warning can also mean a real man-in-the-middle, so `ssh-keyup` asks instead of trusting silently.
179
+
180
+ ### Does `--remove` clean up entries on the device?
181
+
182
+ No. It deletes local key pair and `~/.ssh/config` entry. Line in the device's `authorized_keys` (or `/user/ssh-keys` entry on RouterOS) stays until removed there.
183
+
184
+ ### What devices are supported?
185
+
186
+ Any Linux device reachable over SSH: Raspberry Pi, NVIDIA Jetson, Orange Pi, VMs, servers. Any RouterOS 7.12 or newer device, MikroTik routers or CHR alike, is detected from SSH banner and gets its own key import, `--os routeros` forces it.
187
+
188
+ ### How do I add an SSH key to a MikroTik router from Windows?
189
+
190
+ By hand on RouterOS 7:
191
+
192
+ ```powershell
193
+ ssh-keygen -t ed25519
194
+ scp $env:USERPROFILE\.ssh\id_ed25519.pub admin@192.168.88.1:
195
+ ssh admin@192.168.88.1 "/user/ssh-keys/import public-key-file=id_ed25519.pub user=admin"
196
+ ```
197
+
198
+ Works, with two password prompts and the default key shared across devices again. `ssh-keyup admin@192.168.88.1 router` does it in one session with one prompt, RouterOS is detected from SSH banner. Login user needs `policy` permission (`full` group has it) and firmware 7.12 or newer, older RouterOS rejects Ed25519 keys with `unable to load key file (wrong format or bad passphrase)`.
199
+
200
+ ### Why does RouterOS refuse my password over SSH after adding a key?
201
+
202
+ That is the default: once a user has a key, RouterOS stops accepting that user's password over SSH. WinBox and WebFig are unaffected, and password SSH can be turned back on under `/ip/ssh`.
@@ -0,0 +1,176 @@
1
+ # ssh-keyup
2
+
3
+ ![CI](https://github.com/Kurokesu/ssh-keyup/actions/workflows/ci.yml/badge.svg)
4
+ ![PyPI](https://img.shields.io/pypi/v/ssh-keyup)
5
+ ![Python](https://img.shields.io/badge/python-3.8%2B-brightgreen)
6
+ ![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux-blue)
7
+
8
+ **Set up passwordless SSH in one command on any Linux or RouterOS device, such as Raspberry Pi, NVIDIA Jetson or MikroTik routers.**
9
+
10
+ Tired of juggling `ssh-keygen`, `ssh-copy-id` (missing on Windows) and `~/.ssh/config` edits every time you set up a new device?
11
+
12
+ **`ssh-keyup`** handles all three in one interactive session.
13
+
14
+ ![One ssh-keyup session setting up a Raspberry Pi, then ssh to mypi alias logging in with no password.](https://raw.githubusercontent.com/Kurokesu/ssh-keyup/main/docs/demo.gif)
15
+
16
+ ## Quickstart
17
+
18
+ Install globally with pip:
19
+
20
+ ```bash
21
+ pip install ssh-keyup
22
+
23
+ ssh-keyup # ready to use anywhere
24
+ ```
25
+
26
+ > **Tip:** If `ssh-keyup` is missing or runs an old version after install, new script sits in a folder outside PATH (pip warns about this). Add that folder to PATH, or install with [pipx](https://pipx.pypa.io/) instead:
27
+ >
28
+ > `pipx install ssh-keyup`
29
+
30
+ Or run directly without installing:
31
+
32
+ ```bash
33
+ git clone https://github.com/Kurokesu/ssh-keyup.git
34
+ cd ssh-keyup
35
+ python ssh_keyup.py # Windows
36
+ python3 ssh_keyup.py # Linux
37
+ ```
38
+
39
+ Follow prompts, enter remote password once and you're done. Alias now works in anything that reads `~/.ssh/config`:
40
+
41
+ **Terminal:**
42
+
43
+ ```bash
44
+ ssh mypi # no password, ever again
45
+ ```
46
+
47
+ **VSCode:** [Remote - SSH](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh) works out of the box. Press `Ctrl+Shift+P`, select **Remote-SSH: Connect to Host** and pick your alias for a full IDE on the device, no password:
48
+
49
+ ![VSCode connecting to the mypi alias over Remote SSH without a password.](https://raw.githubusercontent.com/Kurokesu/ssh-keyup/main/docs/demo-vscode.gif)
50
+
51
+ ## Usage
52
+
53
+ ### Skip prompts
54
+
55
+ ```bash
56
+ ssh-keyup pi@192.168.1.23 mypi # user, host and alias in one go
57
+ ssh-keyup pi@192.168.1.23:2222 mypi # non-default SSH port
58
+ ssh-keyup admin@192.168.88.1 router # RouterOS, detected automatically
59
+ ```
60
+
61
+ Flags (`--host`, `--user`, `--alias`, `--port`, `--os`) work too, see `ssh-keyup --help`
62
+
63
+ ### Set up a fleet
64
+
65
+ ```bash
66
+ for host in 192.168.1.10 192.168.1.11 192.168.1.12; do
67
+ ssh-keyup pi@$host
68
+ done
69
+ ```
70
+
71
+ ### Manage entries
72
+
73
+ List or remove entries ssh-keyup manages:
74
+
75
+ ```bash
76
+ ssh-keyup --list
77
+ ssh-keyup --remove mypi # deletes its key pair too
78
+ ```
79
+
80
+ ## Prerequisites
81
+
82
+ **Python 3.8+** and OpenSSH tools (`ssh`, `ssh-keygen`) in PATH.
83
+
84
+ - **Windows 10/11**: Python from [python.org](https://www.python.org/downloads/) or Microsoft Store. OpenSSH Client via Settings > Optional Features or [Git for Windows](https://gitforwindows.org).
85
+ - **Linux**: `sudo apt install python3 openssh-client` (usually pre-installed).
86
+
87
+ ## How it works
88
+
89
+ ```mermaid
90
+ flowchart LR
91
+ run["ssh-keyup"] --> check["check connection"]
92
+ check --> gen["generate ed25519 key<br/>~/.ssh/id_ed25519_mypi"]
93
+ gen --> deploy["deploy public key<br/>~/.ssh/authorized_keys<br/>or /user/ssh-keys on RouterOS"]
94
+ deploy --> config["update ssh config<br/>~/.ssh/config"]
95
+ ```
96
+
97
+ ## Features
98
+
99
+ - Works on **Windows OpenSSH**, where `ssh-copy-id` does not exist
100
+ - **Never touches your password**. Only the public key is piped over SSH and OpenSSH prompts for the password itself
101
+ - One **Ed25519** key per device (`~/.ssh/id_ed25519_<alias>`), not one key reused everywhere
102
+ - Deploys in a **single SSH session**, one password prompt total
103
+ - Adds a named entry to `~/.ssh/config`, works instantly with `ssh <alias>` and VSCode Remote SSH
104
+ - Checks host is **reachable** first, so typos surface before keys exist
105
+ - Detects **RouterOS** and imports the key its way
106
+ - Recovers from **host key mismatches** after a reflash
107
+ - **Entry management**, list or retire devices without leaving stale keys behind
108
+ - **Zero dependencies**, standard library plus system OpenSSH
109
+
110
+ ## FAQ
111
+
112
+ ### Why not do it by hand?
113
+
114
+ Usual commands for passwordless SSH from Windows:
115
+
116
+ ```powershell
117
+ ssh-keygen -t ed25519
118
+ type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh pi@raspberrypi.local "cat >> ~/.ssh/authorized_keys"
119
+ notepad $env:USERPROFILE\.ssh\config # then add a Host block by hand
120
+ ```
121
+
122
+ Works once. Same key lands on every device, `~/.ssh` keeps default permissions that sshd may reject and each new device means another config edit.
123
+
124
+ ### Why not ssh-copy-id?
125
+
126
+ `ssh-copy-id` appends a key to `authorized_keys` and stops there. Windows OpenSSH does not ship it at all and RouterOS has no `authorized_keys` to append to.
127
+
128
+ | | ssh-keyup | ssh-copy-id |
129
+ |---|:---:|:---:|
130
+ | Works on Windows OpenSSH | yes | no |
131
+ | Works with RouterOS | yes | no |
132
+ | Ed25519 key per device | yes | no |
133
+ | Sets `authorized_keys` permissions | yes | yes |
134
+ | Writes `~/.ssh/config` alias | yes | no |
135
+ | Recovers from changed host key | yes | no |
136
+ | Entry management | yes | no |
137
+
138
+ ### How do I fix "REMOTE HOST IDENTIFICATION HAS CHANGED"?
139
+
140
+ Reflashing creates a new host key, so next `ssh` refuses to connect:
141
+
142
+ ```text
143
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
144
+ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
145
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
146
+ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
147
+ ...
148
+ Offending ECDSA key in ~/.ssh/known_hosts:3
149
+ Host key verification failed.
150
+ ```
151
+
152
+ Run `ssh-keyup` again. It detects a changed key, shows new fingerprint for confirmation, clears stale `known_hosts` entry with `ssh-keygen -R` and redeploys. Usually a reflash is behind it, but this warning can also mean a real man-in-the-middle, so `ssh-keyup` asks instead of trusting silently.
153
+
154
+ ### Does `--remove` clean up entries on the device?
155
+
156
+ No. It deletes local key pair and `~/.ssh/config` entry. Line in the device's `authorized_keys` (or `/user/ssh-keys` entry on RouterOS) stays until removed there.
157
+
158
+ ### What devices are supported?
159
+
160
+ Any Linux device reachable over SSH: Raspberry Pi, NVIDIA Jetson, Orange Pi, VMs, servers. Any RouterOS 7.12 or newer device, MikroTik routers or CHR alike, is detected from SSH banner and gets its own key import, `--os routeros` forces it.
161
+
162
+ ### How do I add an SSH key to a MikroTik router from Windows?
163
+
164
+ By hand on RouterOS 7:
165
+
166
+ ```powershell
167
+ ssh-keygen -t ed25519
168
+ scp $env:USERPROFILE\.ssh\id_ed25519.pub admin@192.168.88.1:
169
+ ssh admin@192.168.88.1 "/user/ssh-keys/import public-key-file=id_ed25519.pub user=admin"
170
+ ```
171
+
172
+ Works, with two password prompts and the default key shared across devices again. `ssh-keyup admin@192.168.88.1 router` does it in one session with one prompt, RouterOS is detected from SSH banner. Login user needs `policy` permission (`full` group has it) and firmware 7.12 or newer, older RouterOS rejects Ed25519 keys with `unable to load key file (wrong format or bad passphrase)`.
173
+
174
+ ### Why does RouterOS refuse my password over SSH after adding a key?
175
+
176
+ That is the default: once a user has a key, RouterOS stops accepting that user's password over SSH. WinBox and WebFig are unaffected, and password SSH can be turned back on under `/ip/ssh`.
@@ -1,7 +1,7 @@
1
1
  [metadata]
2
2
  name = ssh-keyup
3
3
  version = attr: ssh_keyup.__version__
4
- description = Passwordless SSH setup and ssh-copy-id alternative for Raspberry Pi, NVIDIA Jetson or any Linux device
4
+ description = Passwordless SSH setup and ssh-copy-id alternative for any Linux or RouterOS device, such as Raspberry Pi, NVIDIA Jetson or MikroTik routers
5
5
  long_description = file: README.md
6
6
  long_description_content_type = text/markdown
7
7
  author = UAB Kurokesu
@@ -12,7 +12,7 @@ project_urls =
12
12
  Repository = https://github.com/Kurokesu/ssh-keyup
13
13
  Issues = https://github.com/Kurokesu/ssh-keyup/issues
14
14
  Changelog = https://github.com/Kurokesu/ssh-keyup/releases
15
- keywords = ssh, ssh-keys, ssh-config, ssh-copy-id, passwordless-ssh, openssh, ed25519, raspberry-pi, rpi, jetson, iot, automation, vscode, remote-ssh, windows, linux
15
+ keywords = ssh, ssh-keys, ssh-config, ssh-copy-id, passwordless-ssh, openssh, ed25519, raspberry-pi, rpi, jetson, mikrotik, routeros, iot, automation, vscode, remote-ssh, windows, linux
16
16
  classifiers =
17
17
  Development Status :: 5 - Production/Stable
18
18
  Environment :: Console
@@ -21,6 +21,7 @@ classifiers =
21
21
  Operating System :: Microsoft :: Windows
22
22
  Operating System :: POSIX :: Linux
23
23
  Programming Language :: Python :: 3
24
+ Topic :: System :: Networking
24
25
  Topic :: System :: Systems Administration
25
26
  Topic :: Utilities
26
27
 
@@ -0,0 +1,202 @@
1
+ Metadata-Version: 2.4
2
+ Name: ssh-keyup
3
+ Version: 1.3.0
4
+ Summary: Passwordless SSH setup and ssh-copy-id alternative for any Linux or RouterOS device, such as Raspberry Pi, NVIDIA Jetson or MikroTik routers
5
+ Home-page: https://github.com/Kurokesu/ssh-keyup
6
+ Author: UAB Kurokesu
7
+ License: GPL-3.0-or-later
8
+ Project-URL: Repository, https://github.com/Kurokesu/ssh-keyup
9
+ Project-URL: Issues, https://github.com/Kurokesu/ssh-keyup/issues
10
+ Project-URL: Changelog, https://github.com/Kurokesu/ssh-keyup/releases
11
+ Keywords: ssh,ssh-keys,ssh-config,ssh-copy-id,passwordless-ssh,openssh,ed25519,raspberry-pi,rpi,jetson,mikrotik,routeros,iot,automation,vscode,remote-ssh,windows,linux
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: System Administrators
16
+ Classifier: Operating System :: Microsoft :: Windows
17
+ Classifier: Operating System :: POSIX :: Linux
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Topic :: System :: Networking
20
+ Classifier: Topic :: System :: Systems Administration
21
+ Classifier: Topic :: Utilities
22
+ Requires-Python: >=3.8
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Dynamic: license-file
26
+
27
+ # ssh-keyup
28
+
29
+ ![CI](https://github.com/Kurokesu/ssh-keyup/actions/workflows/ci.yml/badge.svg)
30
+ ![PyPI](https://img.shields.io/pypi/v/ssh-keyup)
31
+ ![Python](https://img.shields.io/badge/python-3.8%2B-brightgreen)
32
+ ![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux-blue)
33
+
34
+ **Set up passwordless SSH in one command on any Linux or RouterOS device, such as Raspberry Pi, NVIDIA Jetson or MikroTik routers.**
35
+
36
+ Tired of juggling `ssh-keygen`, `ssh-copy-id` (missing on Windows) and `~/.ssh/config` edits every time you set up a new device?
37
+
38
+ **`ssh-keyup`** handles all three in one interactive session.
39
+
40
+ ![One ssh-keyup session setting up a Raspberry Pi, then ssh to mypi alias logging in with no password.](https://raw.githubusercontent.com/Kurokesu/ssh-keyup/main/docs/demo.gif)
41
+
42
+ ## Quickstart
43
+
44
+ Install globally with pip:
45
+
46
+ ```bash
47
+ pip install ssh-keyup
48
+
49
+ ssh-keyup # ready to use anywhere
50
+ ```
51
+
52
+ > **Tip:** If `ssh-keyup` is missing or runs an old version after install, new script sits in a folder outside PATH (pip warns about this). Add that folder to PATH, or install with [pipx](https://pipx.pypa.io/) instead:
53
+ >
54
+ > `pipx install ssh-keyup`
55
+
56
+ Or run directly without installing:
57
+
58
+ ```bash
59
+ git clone https://github.com/Kurokesu/ssh-keyup.git
60
+ cd ssh-keyup
61
+ python ssh_keyup.py # Windows
62
+ python3 ssh_keyup.py # Linux
63
+ ```
64
+
65
+ Follow prompts, enter remote password once and you're done. Alias now works in anything that reads `~/.ssh/config`:
66
+
67
+ **Terminal:**
68
+
69
+ ```bash
70
+ ssh mypi # no password, ever again
71
+ ```
72
+
73
+ **VSCode:** [Remote - SSH](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh) works out of the box. Press `Ctrl+Shift+P`, select **Remote-SSH: Connect to Host** and pick your alias for a full IDE on the device, no password:
74
+
75
+ ![VSCode connecting to the mypi alias over Remote SSH without a password.](https://raw.githubusercontent.com/Kurokesu/ssh-keyup/main/docs/demo-vscode.gif)
76
+
77
+ ## Usage
78
+
79
+ ### Skip prompts
80
+
81
+ ```bash
82
+ ssh-keyup pi@192.168.1.23 mypi # user, host and alias in one go
83
+ ssh-keyup pi@192.168.1.23:2222 mypi # non-default SSH port
84
+ ssh-keyup admin@192.168.88.1 router # RouterOS, detected automatically
85
+ ```
86
+
87
+ Flags (`--host`, `--user`, `--alias`, `--port`, `--os`) work too, see `ssh-keyup --help`
88
+
89
+ ### Set up a fleet
90
+
91
+ ```bash
92
+ for host in 192.168.1.10 192.168.1.11 192.168.1.12; do
93
+ ssh-keyup pi@$host
94
+ done
95
+ ```
96
+
97
+ ### Manage entries
98
+
99
+ List or remove entries ssh-keyup manages:
100
+
101
+ ```bash
102
+ ssh-keyup --list
103
+ ssh-keyup --remove mypi # deletes its key pair too
104
+ ```
105
+
106
+ ## Prerequisites
107
+
108
+ **Python 3.8+** and OpenSSH tools (`ssh`, `ssh-keygen`) in PATH.
109
+
110
+ - **Windows 10/11**: Python from [python.org](https://www.python.org/downloads/) or Microsoft Store. OpenSSH Client via Settings > Optional Features or [Git for Windows](https://gitforwindows.org).
111
+ - **Linux**: `sudo apt install python3 openssh-client` (usually pre-installed).
112
+
113
+ ## How it works
114
+
115
+ ```mermaid
116
+ flowchart LR
117
+ run["ssh-keyup"] --> check["check connection"]
118
+ check --> gen["generate ed25519 key<br/>~/.ssh/id_ed25519_mypi"]
119
+ gen --> deploy["deploy public key<br/>~/.ssh/authorized_keys<br/>or /user/ssh-keys on RouterOS"]
120
+ deploy --> config["update ssh config<br/>~/.ssh/config"]
121
+ ```
122
+
123
+ ## Features
124
+
125
+ - Works on **Windows OpenSSH**, where `ssh-copy-id` does not exist
126
+ - **Never touches your password**. Only the public key is piped over SSH and OpenSSH prompts for the password itself
127
+ - One **Ed25519** key per device (`~/.ssh/id_ed25519_<alias>`), not one key reused everywhere
128
+ - Deploys in a **single SSH session**, one password prompt total
129
+ - Adds a named entry to `~/.ssh/config`, works instantly with `ssh <alias>` and VSCode Remote SSH
130
+ - Checks host is **reachable** first, so typos surface before keys exist
131
+ - Detects **RouterOS** and imports the key its way
132
+ - Recovers from **host key mismatches** after a reflash
133
+ - **Entry management**, list or retire devices without leaving stale keys behind
134
+ - **Zero dependencies**, standard library plus system OpenSSH
135
+
136
+ ## FAQ
137
+
138
+ ### Why not do it by hand?
139
+
140
+ Usual commands for passwordless SSH from Windows:
141
+
142
+ ```powershell
143
+ ssh-keygen -t ed25519
144
+ type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh pi@raspberrypi.local "cat >> ~/.ssh/authorized_keys"
145
+ notepad $env:USERPROFILE\.ssh\config # then add a Host block by hand
146
+ ```
147
+
148
+ Works once. Same key lands on every device, `~/.ssh` keeps default permissions that sshd may reject and each new device means another config edit.
149
+
150
+ ### Why not ssh-copy-id?
151
+
152
+ `ssh-copy-id` appends a key to `authorized_keys` and stops there. Windows OpenSSH does not ship it at all and RouterOS has no `authorized_keys` to append to.
153
+
154
+ | | ssh-keyup | ssh-copy-id |
155
+ |---|:---:|:---:|
156
+ | Works on Windows OpenSSH | yes | no |
157
+ | Works with RouterOS | yes | no |
158
+ | Ed25519 key per device | yes | no |
159
+ | Sets `authorized_keys` permissions | yes | yes |
160
+ | Writes `~/.ssh/config` alias | yes | no |
161
+ | Recovers from changed host key | yes | no |
162
+ | Entry management | yes | no |
163
+
164
+ ### How do I fix "REMOTE HOST IDENTIFICATION HAS CHANGED"?
165
+
166
+ Reflashing creates a new host key, so next `ssh` refuses to connect:
167
+
168
+ ```text
169
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
170
+ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
171
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
172
+ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
173
+ ...
174
+ Offending ECDSA key in ~/.ssh/known_hosts:3
175
+ Host key verification failed.
176
+ ```
177
+
178
+ Run `ssh-keyup` again. It detects a changed key, shows new fingerprint for confirmation, clears stale `known_hosts` entry with `ssh-keygen -R` and redeploys. Usually a reflash is behind it, but this warning can also mean a real man-in-the-middle, so `ssh-keyup` asks instead of trusting silently.
179
+
180
+ ### Does `--remove` clean up entries on the device?
181
+
182
+ No. It deletes local key pair and `~/.ssh/config` entry. Line in the device's `authorized_keys` (or `/user/ssh-keys` entry on RouterOS) stays until removed there.
183
+
184
+ ### What devices are supported?
185
+
186
+ Any Linux device reachable over SSH: Raspberry Pi, NVIDIA Jetson, Orange Pi, VMs, servers. Any RouterOS 7.12 or newer device, MikroTik routers or CHR alike, is detected from SSH banner and gets its own key import, `--os routeros` forces it.
187
+
188
+ ### How do I add an SSH key to a MikroTik router from Windows?
189
+
190
+ By hand on RouterOS 7:
191
+
192
+ ```powershell
193
+ ssh-keygen -t ed25519
194
+ scp $env:USERPROFILE\.ssh\id_ed25519.pub admin@192.168.88.1:
195
+ ssh admin@192.168.88.1 "/user/ssh-keys/import public-key-file=id_ed25519.pub user=admin"
196
+ ```
197
+
198
+ Works, with two password prompts and the default key shared across devices again. `ssh-keyup admin@192.168.88.1 router` does it in one session with one prompt, RouterOS is detected from SSH banner. Login user needs `policy` permission (`full` group has it) and firmware 7.12 or newer, older RouterOS rejects Ed25519 keys with `unable to load key file (wrong format or bad passphrase)`.
199
+
200
+ ### Why does RouterOS refuse my password over SSH after adding a key?
201
+
202
+ That is the default: once a user has a key, RouterOS stops accepting that user's password over SSH. WinBox and WebFig are unaffected, and password SSH can be turned back on under `/ip/ssh`.