0

Need to resolve this issue, Here's the output using -v option:

emarguli@DESKTOP-6C25GHF:/$ ssh -v localhost
OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/emarguli/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/emarguli/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/emarguli/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/emarguli/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/emarguli/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/emarguli/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/emarguli/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/emarguli/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.4
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to localhost:22 as 'emarguli'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: [email protected]
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:lUNGPHQv3Mh7sr4p6aIz/fW5r8uTRrJrBfHo9nk1gRk
debug1: Host 'localhost' is known and matches the ECDSA host key.
debug1: Found key in /home/emarguli/.ssh/known_hosts:1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/emarguli/.ssh/id_rsa
debug1: Trying private key: /home/emarguli/.ssh/id_dsa
debug1: Trying private key: /home/emarguli/.ssh/id_ecdsa
debug1: Trying private key: /home/emarguli/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).

1 Answer 1

1

The clue is the multiple key_load_public: No such file or directory. You have no keys generated, while the server is expecting them.

Use ssh-keygen to create your keys, then try again. Simply invoking ssh-keygen as the emarguli user will create an RSA key for you that should get you going.

For more options, read the man page.

After creating the keys, you need to upload the public key to the remote server so that it trusts the private key that you have on the client. Normally, this can be done using the ssh-copy-id command:

$ ssh-copy-id <user>@<server>

but as you're connecting to your local computer, you can simply append the public RSA key ~/.ssh/id_rsa.pub to your authorized keys file ~/.ssh/authorized_keys:

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

Finally, make sure permissions on this last file are correct - it should only be writable by its owner:

chown 0640 ~/.ssh/authorized_keys
3
  • After ssh-keygen execution I can see new files in ~/.ssh dir:
    – Eugene
    Aug 7, 2018 at 19:55
  • After ssh-keygen execution I can see new files in ~/.ssh dir: emarguli@DESKTOP-6C25GHF:/$ ls -al ~/.ssh total 4 drwx------ 1 emarguli emarguli 4096 Aug 7 14:25 . drwxr-xr-x 1 emarguli emarguli 4096 Aug 7 14:25 .. -rw------- 1 emarguli emarguli 1675 Aug 7 14:17 id_rsa -rw-r--r-- 1 emarguli emarguli 406 Aug 7 14:17 id_rsa.pub -rw-r--r-- 1 emarguli emarguli 222 Aug 5 15:42 known_hosts But now I'm getting another error: emarguli@DESKTOP-6C25GHF:/$ ssh localhost ssh: connect to host localhost port 22: Connection refused emarguli@DESKTOP-6C25GHF:/$
    – Eugene
    Aug 7, 2018 at 20:15
  • I've restarted ssh service and I no longer get "Connection refused". I still have the issue with Permission denied (publickey).
    – Eugene
    Aug 7, 2018 at 20:47

You must log in to answer this question.

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