Skip to content

Instantly share code, notes, and snippets.

@phx
Created June 13, 2013 22:59
Show Gist options
  • Save phx/5778141 to your computer and use it in GitHub Desktop.
Save phx/5778141 to your computer and use it in GitHub Desktop.
will automatically exchange ssh keys with remote server, allowing automatic future password-less access to the remote location from current location. edit as needed if remote location doesn't run sshd on default port.
#!/bin/bash
printf "enter username@ip-address: " ; read UIP ; ssh $UIP "mkdir .ssh 2>/dev/null ; echo $(cat $HOME/.ssh/id_rsa.pub) >>.ssh/authorized_keys ; chmod 700 .ssh ; chmod 600 .ssh/authorized_keys" ; echo "hostname=$(ssh $UIP hostname)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment