Ubuntu – Unable to connect to remote server via SSH (requires public key)

ssh

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 🙂

Best Answer

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