Tag Archives: ssh

Passwordless SSH log in for MAC OS X

On the machine that you want to use to ssh to the other OS X machine do this:

– Create id_rsa key.
when prompted use the suggested filename, and (I strongly recommend to select a passphrase)

ssh-keygen

– Copy public key from ~/.ssh/id_rsa.pub to your server location (in the example below 10.20.30.40)

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

– If you didn’t specify a passphrase, at this point you will be able to ssh to your server.

If you add a passphrase

You will need one more extra step to store the passphrase in the keychain so you won’t be asked to type it over and over again.
– Create a file in ~/.ssh/config
– Add these contents

Host *
   AddKeysToAgent yes
   UseKeychain yes

Now once you enter the passphrase, OS X wont ask you again.

Debugging SSH issues on OS X

Most common problems could be:

Directory permissions

directory permission permission code
/Users/[usename] 755 rwxr-xr-x
/Users/[usename]/.ssh 700 rwx——
/Users/[usename]/.ssh/id_rsa 600 rw——-

Modifications in SSH config files /etc/ssh/sshd_config

How to debug 

On the server:

– You could run another SSH process on different port, and monitor console log.

$ sudo /usr/sbin/sshd -d -p 4444

The client:

– Connect to the newly instantiated SSH process on port 4444 (-p 4444) with -v (verbose) option and monitor the log.

ssh -v -p 4444 tmux@10.0.1.4 -i ~/.ssh/tmux_ssh

Once you find the issue and fix it, you could restart the SSH server with the following commands:

$ sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
$ sudo launchctl load /System/Library/LaunchDaemons/ssh.plist