Using a private key with SSH in terminal

Before you get the wrong idea, I am not looking for how to generate one. I have a key from a server admin but I can't figure out how to use it in OS X.

I have the key, the address and everything I should need but there doesn't seem to be a step by step on how to install the key and use it in terminal.

There was a tutorial on how to add it to Keychain and a few other examples but they were generally centered around using it with that companies server or Amazon and I just can't figure it out.

So, if anyone would PLEASE help me a step by step tutorial, I would be very grateful!

I have to SSH and SCP files to the sever who's site I am working on. I can use terminal well enough but am not against a UI program if that makes more sense.

Thanks!

---------- Post updated at 01:54 PM ---------- Previous update was at 01:45 PM ----------

Additional info: the key is an RSA key

create the key, if u already have no need..

$ ssh-keygen -t rsa

copy the public key to remote servers

ssh-copy-id -i ~/.ssh/id_rsa.pub username@remote

This will prompt you for the login password for the host, then copy the keyfile for you, creating the correct directory and fixing the permissions as necessary.

I have the key file sent to me from the server admin and it is in the .ssh folder but when I try to ssh to the server address, it tells me access is denied (public key).

Based on your info above, can I assume that having the file in the .ssh folder should be all I need to do on this end? There's no installation needed?

which key are you having ?? the public key or the private key?? if you have been give the public key, then you need to copy that public key (id_rsa.pub) thats in your .ssh directory to the remote server. to copy the key to the remote server use the command

ssh-copy-id -i ~/.ssh/id_rsa.pub username@remote

it will ask for the remote server;s password once and then it will copy the id_rsa.pub file content to the remote server's and also assign neccessary permissions. if the above command doesnt work, then you can manually copy the key using

ssh username@host 'cat >> ~/.ssh/authorized_keys' < ~/.ssh/id_rsa.pub

for more information read this
Password-less logins with OpenSSH

---------- Post updated at 12:08 AM ---------- Previous update was at 12:05 AM ----------

hey i used it in unix/Linux system. i dont know how to do it in OS X.. sorry i just read you have specified OS X

1 Like

No, I think you may have answered it for me! I didn't realize what you were saying was that it had to be copied to the server. I incorrectly thought that what I was getting just had to be input on my side and it would identify me to the server. Didn't realize I had to upload my key to the server.

Makes complete sense coupled with what you just told me. I have both files and did not know what I was doing with them. lol

Thanks for the link, it's making it very clear now. :smiley:

---------- Post updated at 03:22 PM ---------- Previous update was at 03:20 PM ----------

BTW, Little, OS X is a UNIX system with a pretty cover is all. I was using the terminal application to do all this so the principles are the same. I think OS X uses BASH.