So i've been given access to ssh a server. I have the username/password, but server apparently requires a public key (now bear in mind that i am a noob in ssh). When I do:

ssh -p 52 user@server.com

terminal says Permission denied (publickey). So I went using

ssh-keygen -t rsa

and got myself the id_rsa and id_rsa.pub files in /root/.ssh. Chmoded /root/.ssh to 700 and /root/.ssh/* to 600. Tried sshing server.com again, same error.

What am I missing? I've been given a Putty Pagant Key file (.ppk) by the SYSADMIN of server.com. Apparently, other users (all Windows) can connect using Putty Pagant.exe. Please help :)

4 Answers 4


If you have been given the .ppk file by the sysadmin, you can use puttygen to create the ssh key files (install putty-tools from software centre)

Install putty:
sudo apt install putty putty-tools
Create the public key file:
puttygen /path/to/puttykey.ppk -L > ~/.ssh/id_rsa.pub
Create the private key file:
puttygen /path/to/puttykey.ppk -O private-openssh -o ~/.ssh/id_rsa

also, there are some mac instructions which should also work

Note that when running command

puttygen /path/to/puttykey.ppk -O private-openssh -o ~/.ssh/id_rsa

it may ask for password to decrypt the key, plus you should run it as the user which will make the ssh connection so that it stores the key in the correct directory (the ~ symbol is equivalent to the home directory of the current user) Then after checking the chmod permissions are correct you can use

ssh -p 52 user@server.com
  • awesome! not only it fixed the problem (i've followed the instructions enclosed in first link) but I also understood HOW it works! SSH kicks ass! Thanks @Simon B
    – fabjoa
    Feb 9, 2011 at 6:27
  • Perfect solution.....!!!!! Apr 21, 2021 at 13:27

The answers to this question may help you. In general, to be able to use public key authentication you would have had to have copied your private key over to the other server first; so unless the sysadmin gave you a public/private key pair that's already on the server, you won't be able to log into it with that.

ssh-keygen (press enter enter enter till you get the image)
user@ubuntu1:~$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa): 
/home/user/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again: 
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
5e:80:dd:36:0f:00:b6:58:bc:ae:a4:87:c8:bd:c1:f8 user@ubuntu1
The key's randomart image is:
+--[ RSA 2048]----+
|     .+..        |
|     +.+ o       |
|    . o.o =      |
|      .  o +     |
|     .  S . .    |
|  o . .. .       |
|.o.* .  .        |
|..+.+            |
|   E.            |

ssh-copy-id -i user@server.com. 

You will see the following

(Once it will ask for the password)

user@ubuntu1:~$ ssh-copy-id -i root@ip
root@ip's password: 

Now try logging into the machine, with "ssh 'root@ip'", and check in:


to make sure we haven't added extra keys that you weren't expecting.

  • Now you should be able to perform ssh without asking for password
  • 1
    It would be helpful if you provided some additional explanation to make your answer useful Mar 29, 2013 at 6:18
  • Dear, you did a good job but lost your concentrate, there is two steps, whatever, thanks for the great idea, I just over come.

    ssh-keygen -t rsa
    ssh-keygen -t dsa 
    cd /root/.ssh/ 
    cp **** /etc/ssh/ 

    now replace 4 the respective files

  • 4
    Welcome to Ask Ubuntu! Could you please try to rephrase your answer a bit? I don't really understand what you are trying to say. Feb 13, 2012 at 20:19

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.