0

Can I generate one SSH key and then use this key to SSH server from any operating system like mac, windows, sunsolaris or linux command shell?

UPDATE:

  1. I have a dedicated server and I may access it as a root from different Operating Systems
  2. The server is not shared to any user. Will it be better to generate SSH key on server or client machines?

Thanks

6
  • 1
    Yes. This seems to be well-explained here, along with useful links describing different ways of copying existing keys to other machines.
    – yahol
    Commented Mar 23, 2018 at 14:50
  • 1
    That's the NORMAL thing to do! It'd take a more effort and a little bit more knowledge to do use different keys for different operating systems/computers! So you do the normal thing. You generate the public and private key, keep the private key private. Send the public key to those computers. Any ssh key explanation will tell you.
    – barlop
    Commented Mar 23, 2018 at 14:56
  • may I generate key on the server and then use it on any client machine? OR I have to generate key on client machine and then transfer to server? Furthermore, I want to use this key to access root
    – LifeSaver
    Commented Mar 23, 2018 at 15:08
  • In the general case it is best to generate the key on the client, because if the server is shared, another user could get access to the private key. Having one key per client isn't much more difficult and could be simpler to handle...
    – xenoid
    Commented Mar 23, 2018 at 15:16
  • @xenoid I agree with one key per client but if there is one key identity on the server then I can not login to the server without key. How do I connect to the server to upload another key in this case?
    – LifeSaver
    Commented Mar 23, 2018 at 15:20

1 Answer 1

0

you have access to the server? so just create your keys on each client and manually add the PUBLIC key from each to ~/.ssh/authorized_keys on the host you wish to access.

to generate keys: Linux:

ssh-keygen 

Windows: not sure if there is a better way, but I d/l putty tool and use

puttygen

Mac:

ssh-keygen

==== with linux you can copy your keys to the server using

ssh-copy-id root@<server_ip>

not sure how to do that under windows just ( should be a very quick google/SO search ) which is why I suggested adding your keys manually.

Hope it helps you.

4
  • my basic question is that can I generate one ssh key to use on all operating systems? This will be secure and better to have one key instead of different keys for different OS (2) I have bad experience as I generated one key in windows that work fine in windows environment but I am not able to use same key from centos 7
    – LifeSaver
    Commented Mar 23, 2018 at 17:23
  • Ok.. so yes, you can, this is standard usage of ssh keys.You could even generate your keys on one box ( linux for eg ) and copy the private key to correct home/key folder on each system and the public key to the server you wish to access... but please be aware of the dangers of copying your private keys to different clients, there be dragons. but short answer... yes , you can
    – Sean Davey
    Commented Mar 23, 2018 at 17:25
  • Thanks. Why my ssh created on windows environment not working on linux? This is what I cam here and afraid of
    – LifeSaver
    Commented Mar 23, 2018 at 17:37
  • Hello its been some time sinve i generqted ssh keys on windows but if i remember correctly they ate formatted differently. Try to open both (linux and windows keys) in a text editor and compare to see the difference, dont edit the actual hash (long code) of the windows key but try to put it to the same as the linux key, alternatively as i suggested copy your private key from linux to the correct folder on your windows box, and you should be good to go.. (on mobile now so pls excuse formatting)
    – Sean Davey
    Commented Mar 23, 2018 at 17:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .