Could not find id_rsa.pub

10,645

You need to generate your private and public key:

ssh-keygen -t rsa 

And to add your key as an authorized key on the server side:

ssh-copy-id <server hostname/ip address>
Share:
10,645

Related videos on Youtube

Lesha Pipiev
Author by

Lesha Pipiev

Updated on September 18, 2022

Comments

  • Lesha Pipiev
    Lesha Pipiev over 1 year

    I am under cloud Ubuntu 12.04.5 LTS.
    And I couldn't find id_rsa.pub file.

    $ ls -ll ~/.ssh 
    total 12
    -rw------- 1 root root 4435 Jul 22 11:15 authorized_keys
    -rw-r--r-- 1 root root 2660 Jul 22 15:45 known_hosts
    

    In authorized_keys file there are public keys of hosts that can access to the server.
    In known_hosts file there are many repeated chunks of code:

    |1|fg5CCFQU2d3/Ut6EFN8SivyYZpg=|CMkxOukPDy50bualN6lAiobvQc4= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNAAAAIbmlzdHAyNTYAAABBBLPpEXdAdrPJgZuO+lowXVQbyCbzjVLxshDNFlAINvdlMzu3GwgEI/UPGZjTq+n4iBq702Ho7vshj0UtbX9IQDA=
    |1|kSgZ7ya8jCLgz6Uga0wlOzcclSY=|63ZjaYQdxQuBzFZn4sDxoC/zAxE= ecdsa-sha2-nistp256 AAAAE2VjZHNhLoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLPpEXdAdrPJgZuO+lowXVQbyCbzjVLxshDNFlAINvdlMzu3GwgEI/UPGZjTq+n4iBq702Ho7vshj0UtbX9IQDA=
    

    I couldn't figure out where is the server id_rsa.pub.

  • Wilf
    Wilf almost 9 years
    This I think needs to be done on the client machine, and then sent to the server with something like cat .ssh/id_rsa.pub | ssh USERNAME@IP_ADDRESS 'cat >> .ssh/authorized_keys' (on linux atleast)
  • mgor
    mgor almost 9 years
    Updated answer with an easier way to add your key on the server side.
  • Lesha Pipiev
    Lesha Pipiev almost 9 years
    Guys, I am on the server side. An I couldn't find the public key. Does it mean I should generate it?
  • Wilf
    Wilf almost 9 years
    Yeah (i think) if you want to access a server without a pass from a client you need to generate the private and public keys on the client, then copy the public key to the server's .ssh/authorized_keys file
  • mgor
    mgor almost 9 years
    In that case, run ssh-copy-id on your client machine to add your public key I your users authorized_keys on the server. The server side does not necessarily need a public and private key in the .ssh directory.