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>
Related videos on Youtube
Author by
Lesha Pipiev
Updated on September 18, 2022Comments
-
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 almost 9 yearsThis 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 almost 9 yearsUpdated answer with an easier way to add your key on the server side.
-
Lesha Pipiev almost 9 yearsGuys, I am on the server side. An I couldn't find the public key. Does it mean I should generate it?
-
Wilf almost 9 yearsYeah (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 almost 9 yearsIn 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.