Results 1 to 3 of 3

Thread: Execute ssh command with private key

  1. #1
    Join Date
    Dec 2008

    Question Execute ssh command with private key

    I am trying to execute ssh command with a private key for the supplied username.
    Somehow it fails and revert to trying password.

    build@buildserver:~> ssh -v -i private.key
    OpenSSH_6.2p2, OpenSSL 0.9.8j-fips 07 Jan 2009
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 20: Applying options for *
    debug1: Connecting to [] port 22.
    debug1: Connection established.
    debug1: identity file private.key type -1
    debug1: identity file private.key-cert type -1
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_6.2
    debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
    debug1: match: OpenSSH_6.6.1 pat OpenSSH*
    debug1: SSH2_MSG_KEXINIT sent
    debug1: SSH2_MSG_KEXINIT received
    debug1: kex: server->client aes128-ctr none
    debug1: kex: client->server aes128-ctr none
    debug1: sending SSH2_MSG_KEX_ECDH_INIT
    debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
    debug1: Server host key: ECDSA 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 [MD5]
    debug1: Host '' is known and matches the ECDSA host key.
    debug1: Found key in /home/build/.ssh/known_hosts:12
    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,keyboard-interactive
    debug1: Next authentication method: publickey
    debug1: Trying private key: private.key
    debug1: read PEM private key done: type RSA
    debug1: Authentications that can continue: publickey,keyboard-interactive
    debug1: Next authentication method: keyboard-interactive

  2. #2
    Join Date
    Oct 2013

    Default Re: Execute ssh command with private key

    The output shows that key was tried and failed. In this cause you would need to view the logs on the destination machine.

    You can also increase the verbosity of the debugging on your end by going from -v to -vvv.

    I would also suggest you check the private and public key files to ensure they have the same md5 otherwise you will have issues.
    Command: ssh-keygen -l -f {key}

    Check the ownership and permissions of the key. The default is to keep it in .ssh with 750 folder permissions and 600 for key permissions.

    On the receiving system in the .ssh folder(750 permissions) the public key should be in "authorized_keys" with 600 permissions.

  3. #3
    Join Date
    Jun 2008
    San Diego, Ca, USA
    Blog Entries

    Default Re: Execute ssh command with private key

    You can use the following SDB to check whether your setup is correct. Although it's ancient, to my eye the only significant thing that needs to be updated is to substitute the rc commands with systemd commands to stop/start the sshd service

    Beginner Wiki Quickstart -
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts