Harsh Vardhan Ladha Harsh Vardhan Ladha - 1 month ago 25
Linux Question

SSH : ssh-keygen generating rsa key, but not working

I am using

ssh-keygen
and giving no pass phrase then key-fingerprint is successfully generated and shown.

Then I'm giving
ssh-copy-id user@localhost
then its prompting for my user's password after providing it states
Number of key(s) added : 1
.

Now if I'm doing
ssh localhost
its again prompting for password.

also If I do
ssh user@localhost
it asks for password.

PS : I have used :
ssh-add
and also
sudo ufw allow 22
nothing seems to work fine everytime I do
ssh localhost
I have been prompted with password.

[EDIT]

ssh -v localhost


shows


debug1: SSH2_MSG_KEXINIT sent

debug1: SSH2_MSG_KEXINIT received

debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com none

debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com none

debug1: sending SSH2_MSG_KEX_ECDH_INIT

debug1: expecting SSH2_MSG_KEX_ECDH_REPLY

debug1: Server host key: ECDSA b2:58:a9:da:84:3f:43:1c:86:51:ba:cd:b7:88:a3:74

debug1: Host 'localhost' is known and matches the ECDSA host key.

debug1: Found key in /home/harsh/.ssh/known_hosts:1

debug1: ssh_ecdsa_verify: signature correct

debug1: SSH2_MSG_NEWKEYS sent

debug1: expecting SSH2_MSG_NEWKEYS

debug1: SSH2_MSG_NEWKEYS received

debug1: Roaming not allowed by server

debug1: SSH2_MSG_SERVICE_REQUEST sent

debug1: SSH2_MSG_SERVICE_ACCEPT received

debug1: Authentications that can continue: publickey,password

debug1: Next authentication method: publickey

debug1: Offering DSA public key: /home/harsh/.ssh/id_dsa

debug1: Authentications that can continue: publickey,password

debug1: Offering RSA public key: /home/harsh/.ssh/id_rsa

debug1: Authentications that can continue: publickey,password

debug1: Trying private key: /home/harsh/.ssh/id_ecdsa

debug1: Trying private key: /home/harsh/.ssh/id_ed25519

debug1: Next authentication method: password

harsh@localhost's password:

Answer

I managed to overcome this problem by simply re-installing the ssh on my ubuntu machine.

The problem was because ssh wasn't installed properly upon OS installation.