Permission Denied (PublicKey)

September 13, 2018 93 views
Networking Ubuntu

Hey there. For starters, I am a total noob to server set up. What I need to do is set up SSH log in to my VPS. For reference, I am using Ubuntu 14.04 and I used PuttyGen to make my key.

I connected my public key with my DigitalOcean account, and so my new server was made with an SSH included. I have two questions: What are the details that I would need to send someone to allow them to log into my server with SSH?

And finally, whenever I try to log into my server with SSH from a console, by doing a command like: ssh MYIPADDRESS, it says PublicKey Denied. I am able to connect with my private key no problem, but I know that i should not share that and so I must find otherways to connect. Any help is appreciated, thank you.

So basically, I can connect with Putty using private key, but cannot connect any other way!

1 comment
  • Here is my debug log when I do ssh -v MYIP
    root@MollyBabesHost:~# ssh -v 159.203.22.31
    OpenSSH6.6.1, OpenSSL 1.0.1f 6 Jan 2014
    debug1: Reading configuration data /etc/ssh/ssh
    config
    debug1: /etc/ssh/sshconfig line 19: Applying options for *
    debug1: Connecting to 159.203.22.31 [159.203.22.31] port 22.
    debug1: Connection established.
    debug1: permanently
    setuid: 0/0
    debug1: identity file /root/.ssh/id
    rsa type -1
    debug1: identity file /root/.ssh/idrsa-cert type -1
    debug1: identity file /root/.ssh/id
    dsa type -1
    debug1: identity file /root/.ssh/iddsa-cert type -1
    debug1: identity file /root/.ssh/id
    ecdsa type -1
    debug1: identity file /root/.ssh/idecdsa-cert type -1
    debug1: identity file /root/.ssh/id
    ed25519 type -1
    debug1: identity file /root/.ssh/ided25519-cert type -1
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH
    6.6.1p1 Ubuntu-2ubuntu2.10
    debug1: Remote protocol version 2.0, remote software version OpenSSH6.6.1p1 Ubu ntu-2ubuntu2.10
    debug1: match: OpenSSH
    6.6.1p1 Ubuntu-2ubuntu2.10 pat OpenSSH6.6.1* compat 0x04 000000
    debug1: SSH2
    MSGKEXINIT sent
    debug1: SSH2
    MSGKEXINIT 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
    MSGKEXECDHINIT
    debug1: expecting SSH2
    MSGKEXECDHREPLY
    debug1: Server host key: ECDSA 1c:5b:04:f7:15:5f:6d:96:e0:a3:92:dc:66:ed:ab:9f
    debug1: Host '159.203.22.31' is known and matches the ECDSA host key.
    debug1: Found key in /root/.ssh/known
    hosts:1
    debug1: sshecdsaverify: signature correct
    debug1: SSH2MSGNEWKEYS sent
    debug1: expecting SSH2MSGNEWKEYS
    debug1: SSH2MSGNEWKEYS received
    debug1: SSH2MSGSERVICEREQUEST sent
    debug1: SSH2
    MSGSERVICEACCEPT received
    debug1: Authentications that can continue: publickey
    debug1: Next authentication method: publickey
    debug1: Trying private key: /root/.ssh/idrsa
    debug1: Trying private key: /root/.ssh/id
    dsa
    debug1: Trying private key: /root/.ssh/idecdsa
    debug1: Trying private key: /root/.ssh/id
    ed25519
    debug1: No more authentication methods to try.
    Permission denied (publickey).

2 Answers

Hey friend!

Great questions. So the reason for the failure in this case may be that your private key is not in the default location for the OpenSSH CLI client. You say your private key works elsewhere, I assume you're feeding it manually to a different application. You could point OpenSSH to it as well like this:

ssh -i /path/to/privatekey root@serverIP

As for giving someone else access, just ask for their public key and put it in /root/.ssh/authorized_keys on the droplet. They would be able to log in with their own private key then.

Hope this helps :)

Jarland

Have another answer? Share your knowledge.