//TODO: professional stuff of software engineerĀ 1001010
Monthly Archives: January 2016
Note to self: ssh auto login

Sometimes I want ssh to just connect and not ask me for the remote password. By sometimes, I mean last time was 2 years ago.

This works on my mac, your mileage will vary

Make some keys

I like to create unique keys for each site and store them away, for reasons..

$ ssh-keygen -t rsa
Enter file in which to save the key (~/.ssh/id_rsa): ~/.ssh/id_rsa_EXAMPLE_TLD
passphrase: REDACTED
passphrase again: REDACTED
bla bla bla info about the fingerprint & ascii art

Ensure there is a ~/.ssh/ folder on remote

Note: you may have to change permissions on the remote .ssh folder and .ssh/authorized_keys

$ ssh MYUSERNAME@EXAMPLE.TLD mkdir -p .ssh

Send our newly minted public key to the remote

$ cat ~/.ssh/id_rsa_EXAMPLE_TLD.pub | ssh MYUSERNAME@EXAMPLE.TLD 'cat >> ~/.ssh/authorized_keys && chmod 644 ~/.ssh/authorized_keys'

Tell OSX to use our key for this server

$ vim ~/.ssh/config
Host example.tld
	Hostname example.tld
	IdentityFile ~/.ssh/id_rsa_EXAMPLE_TLD
	User MYUSERNAME

Test it out by connecting to it

$ ssh MYUSERNAME@EXAMPLE.TLD
Welcome to EXAMPLE.TLD
Last Login: TIMESTAMP from YOURIP
MYUSERNAME@EXAMPLE.TLD $ _