Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 :)

share|improve this question

4 Answers 4

up vote 7 down vote accepted

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)

http://blog.padraigkitterick.com/2007/09/16/using-putty-ssh-keys-with-openssh-on-ubuntu also, there are some mac instructions here which should also work http://leadingedgescripts.co.uk/server-administration/how-to-convert-your-putty-ppk-private-key-to-a-normal-ssh-key-you-can-use-on-an-apple-mac/

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) you should run it as the user which will make the ssh connection so that it stores the key in the correct directory (~ 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
share|improve this answer
    
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 '11 at 6: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.

share|improve this answer
    
thanks @codeMonk, I actually get it now! –  fabjoa Feb 9 '11 at 6:28
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:

    ~/.ssh/authorized_keys

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
share|improve this answer
1  
It would be helpful if you provided some additional explanation to make your answer useful –  Kevin Bowen Mar 29 '13 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

share|improve this answer
3  
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. –  Octavian Damiean Feb 13 '12 at 20:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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