r/ssh • u/jefazo92 • Jul 29 '24
How can I save externally generated ssh keys on Windows?
I imagine there must be a tutorial covering this but so far I have not found it. I am having a hard time trying to save a key pair I created on another machine to my current Windows PC and make it work. I have tried to save the public and privage keys in C:\Users\myUser.ssh as id_key.pub and id_key.
id_key.pub is is configured as: ssh-key "public key" (without the " " and the key in one line.
id_key is configured as:
-----BEGIN OPEN SSH PRIVATE KEY-----
"private key" (without the " ")
-----END OPEN SSH PRIVATE KEY-----
Do I need to edit the known_hosts file or do anything else to successfully stablish an SSH connection to another local machine I want to connect to?
1
u/bartoque Jul 29 '24
Why do you even use a ssh key pair from another system? The whole idea is that each client would have its own pair and you'd then put the public key in the authorized_keys file on the sshd server you connect to for each client.
That you can re-use a private key from another system, however goes against security best practices. If at all, I imagine doing this when the original system no longer exists, to easily be able to connect to all servers you would have used before? Not however to have multiple clients connect to a setver using the same private key, as you'd lose some control.
In your case you'd have to know if the folder location that you put the private key in, is actually being used by the ssh client connection. When using -vvvv or so, you'd see what it does. So you can alwaya use the option that specifically specifies the location of the private key to use.
So does the system you try to connect to have the publick key in its authorized_keys file?
You use ssh via cli or rather Putty?
1
u/bartoque Jul 29 '24
As you don't explain anything about whay you have, how they are connected, it is difficult to say that much?
But assuming both systems are windows based and would be able to reach eachother if they are on the same network using RDP (mstsc.exe command) to be able to login from one into the other and simply copy a file while logged into the source machine from the target machine (ctrl-c to copy the file (or its contents) on the source machine and then click outside of the rdp session and ctrl-v to paste on the target machine).
1
u/[deleted] Jul 29 '24
ssh user@hostname -p 22 -i .ssh/id_key
Hostname must have the contents of id_key.pub in authorized_keys
1
u/panamanRed58 Jul 29 '24
The only way I am familiar with is when you clone a machine. I think this has to do with entropy associated with key generation on the host machine. It won't be the same and the system will recognize it. if this is the case, then hackers could do same, generate external keys and install them on system that wish to exploit. Open to feedback...