graphicmist

Techno-bits and some graphical adventures of my life

Linux

Use your putty ppk file to ssh remote server in ubuntu

Problem : You have been using winscp tool in windows to access your remote server. Now the geek inside you make a move to linux and you are stuck how to use the passkey used in winscp with openssh client in linux.

Solution: First of all, the .ppk file is putty specific one and you need to convert it to the openssh format, so that it can be used with ssh command in the terminal.

To convert the ppk file download the puutygen tool in ubuntu (the commands vary a lil bit depending on the flavour of linux you are using):

sudo apt-get install putty

This will automatically install the puttygen tool.

Now to convert the ppk file to be used with ssh command execute the following in terminal

puttygen mykey.ppk -O private-openssh -o my-openssh-key
Now, you can easily access to remote server using:

sudo ssh -v user@example.com -i my-openssh-key

Cheers!!!

10 comments

  1. riz - November 23, 2012 6:02 pm

    hi How do you delete a specific key? for example I want to delete the “my-openssh-key” I
    just added?

    Reply
    • Yashrajsinh Jadeja - September 19, 2017 6:12 pm

      “my-openssh-key” will be created in the same directory from where you are running this command. For example, if you are in “Downloads” directory and running this command then “my-openssh-key” will be generated in “Downloads” directory itself. So just delete the generated new file!

      This command just converting the ppk file and not adding it to anywhere. This is different than the “known-hosts” thing. 🙂

      BTW Thank you @graphicmist for this clear article 🙂

      Reply
  2. Robin Tyagi - August 27, 2013 9:51 am

    not working only locking “debug1: Reading configuration data /etc/ssh/ssh_config”

    OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: Applying options for *
    debug1: Connecting to ifeelclub.com [50.16.204.240] port 22.

    Reply
    • graphicmist - August 27, 2013 10:33 am

      you need to specify the correct path of your key after -i parameter in command

      Reply
  3. Raghavendra Chary B - December 31, 2013 10:57 am

    Thanks very much! it worked.

    Reply
  4. Binod - March 4, 2015 11:27 am

    A little bit of explantion about the commands and parameters at the end will make this more complete 🙂

    Reply
    • graphicmist - February 12, 2017 4:57 am

      Thanks for the feedback. I will keep this in mind for future posts

      Reply
  5. Purnendu SIngh - December 2, 2016 3:33 pm

    thanks very helpful for me

    Reply
  6. Beckham - August 23, 2017 8:12 pm

    I presume i was able to connect using the given command but not sure if i was able to connect to the sftp site.

    Below is the log:

    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 19: Applying options for *
    debug1: Connecting to sftp3.****.com [******] port 22.
    debug1: Connection established.
    debug1: permanently_set_uid: 0/0
    debug1: identity file my-openssh-key type -1
    debug1: identity file my-openssh-key-cert type -1
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8
    debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1
    debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 pat OpenSSH_5* compat 0x0c000000
    debug1: SSH2_MSG_KEXINIT sent
    debug1: SSH2_MSG_KEXINIT received
    debug1: kex: server->client aes128-ctr hmac-md5 none
    debug1: kex: client->server aes128-ctr hmac-md5 none
    debug1: sending SSH2_MSG_KEX_ECDH_INIT
    debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
    debug1: Server host key: RSA *****
    debug1: Host ‘****.****.com’ is known and matches the RSA host key.
    debug1: Found key in /root/.ssh/known_hosts:1
    debug1: ssh_rsa_verify: signature correct
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug1: SSH2_MSG_NEWKEYS received
    debug1: SSH2_MSG_SERVICE_REQUEST sent
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug1: Authentications that can continue: publickey
    debug1: Next authentication method: publickey
    debug1: Trying private key: my-openssh-key
    debug1: key_parse_private2: missing begin marker
    debug1: key_parse_private_pem: PEM_read_PrivateKey failed
    debug1: read PEM private key done: type
    Enter passphrase for key ‘my-openssh-key’:
    debug1: key_parse_private2: missing begin marker
    debug1: read PEM private key done: type RSA
    debug1: Authentication succeeded (publickey).
    Authenticated to ****.****.com ([*****22).
    debug1: channel 0: new [client-session]
    debug1: Requesting no-more-sessions@openssh.com
    debug1: Entering interactive session.
    debug1: Sending environment.
    debug1: Sending env LANG = en_US.UTF-8
    debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
    debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
    Welcome to Ubuntu 12.04.1 LTS (GNU/Linux 3.2.0-34-virtual i686)

    * Documentation: https://help.ubuntu.com/

    System information as of Wed Aug 23 15:57:18 EDT 2017

    System load: 0.91 Processes: 274
    Usage of /: 65.4% of 39.37GB Users logged in: 0
    Memory usage: 49% IP address for eth0: 10.154.181.132
    Swap usage: 0%

    => /newdata is using 88.1% of 196.86GB
    => /extra_space is using 89.9% of 492.15GB

    Graph this data and manage this system at https://landscape.canonical.com/
    ———————————————————————
    At the moment, only the core of the system is installed. To tune the
    system to your needs, you can choose to install one or more
    predefined collections of software by running the following
    command:

    sudo tasksel –section server
    ———————————————————————

    427 packages can be updated.
    305 updates are security updates.

    New release ‘12.10’ available.
    Run ‘do-release-upgrade’ to upgrade to it.

    The programs included with the Ubuntu system are free software;
    the exact distribution terms for each program are described in the
    individual files in /usr/share/doc/*/copyright.

    Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
    applicable law.

    Last login: Wed Aug 23 14:35:36 2017 from 12.69.53.50
    /usr/sbin/nologin: No such file or directory
    debug1: channel 0: free: client-session, nchannels 1
    Connection to ******.com closed.
    Transferred: sent 3328, received 4528 bytes, in 0.6 seconds
    Bytes per second: sent 5237.9, received 7126.5
    debug1: Exit status 1

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *