3

Could someone guide me to setting up OSX (10.10 Yosemite) so that I can ssh from Windows using putty to Mac, but using ssh key rather than password.

On the Mac I've enabled remote-login under sharing preferences, but unsure how to setup the private/public keys.

All articles that I find on the web guide how to connect to Linux from Mac, but I want the other way round and where the client is Windows.

PS - I'm a complete noob when it comes to Mac and have only been using it for 2 days now!

2

You will need to use a program called PuttyGen.exe on the Windows side to generate a public and private key.

Using the "Generate" button, generate the keys using the above program. You will then need to move the public key that is generated to your mac. Save a copy of the private key to use later using the "Save private key" button.

On your windows machine copy the contents of your public key exactly and paste them in the authorized_keys file you will create below. The easiest way I think is to open an ssh connection using Putty to your mac machine, the first time you will have to enter a username and password. Then create the folders and file structure and use an editor to move the contents. From the putty terminal window connected to your mac enter:

sudo mkdir ~/.ssh
sudo touch ~/.ssh/authorized_keys
sudo chmod 600 ~/.ssh/authorized_keys
sudo chown root:wheel ~/.ssh/authorized_keys

Then the editing part of the file you created:

vim ~/.ssh/authorized_keys

Press the i key to insert text. Paste in your public key, and press the keys esc then, :wq to save it.

Now you can re-open Putty and create a new session. On the left hand tab expand SSH and select the Auth tab. Towards the bottom you will need to browse and load in the Private key that you saved earlier.

Putty Auth

I got most of this from the help file in PuttyGen.exe the first time I did it. When you open Puttygen.exe there is a Help tab up top.

PuttyGen.exe download

  • This is really helpful - I was sort of figuring these steps out - but unfortunately it isn't working - im getting a message server refused our key - any thoughts? – Chris Moutray Nov 18 '14 at 21:41
  • Does the key type matter? I've used SSH-2-RSA... – Chris Moutray Nov 18 '14 at 21:43
  • Sounds like you are trying to ssh to a user on the mac other than the one that has the authorized_keys file – tron_jones Nov 18 '14 at 21:51
  • 05817:~ chrismoutray$ sudo more ~/.ssh/authorized_keys returns the contents of the public key file - and I'm using the username chrismoutray - I've copied and pasted to make sure no typos – Chris Moutray Nov 18 '14 at 21:55
  • Are you using the hostname to connect through putty, if so try using the IP instead – tron_jones Nov 18 '14 at 21:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .