0

Hello I'm using cmder(Console Emulator) in windows to connect to my VPS

I want to login to ssh using a public key authentication.

In my local computer I have generated a public and private key pair in my home directory in the .ssh folder as in the image below:

enter image description here

I generated a public and private key pair in my VPS in the /root/.ssh folder as shown.

I copied my local computer public key into the authorized_keys in the VPS as shown below:

enter image description here

When I try to login into ssh I get the following error:

ssh -v myuser@XX.XX.XXX.XX -p 2222
OpenSSH_7.3p1, OpenSSL 1.0.2j  26 Sep 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to XX.XX.XXX.XX [XX.XX.XXX.XX] port 2222.
debug1: Connection established.
debug1: identity file /c/Users/Ouss/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Ouss/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Ouss/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Ouss/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Ouss/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Ouss/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Ouss/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Ouss/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000
debug1: Authenticating to XX.XX.XXX.XX:2222 as 'myuser'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: umac-64@openssh.com compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: umac-64@openssh.com compression: none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<3072<8192) sent
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:R0Wzw4nu+ko/G13Og1JgIViSkSAGk/Wzg9y2eRSsgU0
debug1: Host '[XX.XX.XXX.XX]:2222' is known and matches the RSA host key.
debug1: Found key in /c/Users/Ouss/.ssh/known_hosts:1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_ACCEPT received


debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /c/Users/Ouss/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: Trying private key: /c/Users/Ouss/.ssh/id_dsa
debug1: Trying private key: /c/Users/Ouss/.ssh/id_ecdsa
debug1: Trying private key: /c/Users/Ouss/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

Here is my ssh_config:

# Authentication:

#LoginGraceTime 2m
PermitRootLogin no
StrictModes yes
MaxAuthTries 3
#MaxSessions 10

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile      ssh/authorized_keys
#AuthorizedKeysCommand none
#AuthorizedKeysCommandRunAs nobody

Can you help me with this please?

  • I could not add a comment on your question so answering here. Can you please list the permission of the authorization_key and .ssh folder in your home directory. Also Please see the auth/secure log in messages it will give you a better idea what is happening. If it is possible please paste them here, I will help you. -- – tollboy Jul 24 '17 at 9:57
  • The key is rejected. Please, show us the permissions of the authorized_keys file and its parent directories including selinux labels. Also AuthorizedKeysFile ssh/authorized_keys is missing the . in front of the path – Jakuje Jul 24 '17 at 10:36
  • -rw-r--r-- 1 Ouss 197121 3326 Jul 21 13:20 id_rsa -rw-r--r-- 1 Ouss 197121 749 Jul 21 13:20 id_rsa.pub -rw-r--r-- 1 Ouss 197121 401 Jul 21 14:03 known_hosts I don't have authorization_key in my home/.ssh folder – user754144 Jul 24 '17 at 11:04
  • Only the user/omer shoulder have read permission for the .ssh and inside stuff. Are you able to see the logs on the server, where you are trying to connect – tollboy Jul 24 '17 at 11:08
  • I cleared the log in /var/log/secure so I can see fresh errors, now It seems that no logs are saved anymore in /var/log/secure – user754144 Jul 24 '17 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.