Skip to content

Instantly share code, notes, and snippets.

@papaver
Created December 12, 2013 20:11
Show Gist options
  • Save papaver/7934592 to your computer and use it in GitHub Desktop.
Save papaver/7934592 to your computer and use it in GitHub Desktop.
Setup Passless Login For SSH
#!/bin/tcsh
# validate command-line args
if ($# != 2) then
echo "Example usage: $0 ssh.codeisart.com 22"
exit 1
endif
# set script variables
set remotehost = $1
set port = $2
# start in home dir
cd ~
pwd
# create key?
if (! -f ~/.ssh/id_rsa.pub) then
echo "->> Creating RSA Key <<-"
ssh-keygen -b 4096
endif
# log into remote server and update ssh key
echo "->> Sending Key to ${remotehost}:${port} <<-"
ssh ${remotehost} -p ${port} mkdir .ssh
ssh ${remotehost} -p ${port} chmod 700 .ssh
ssh ${remotehost} -p ${port} cat \>\> .ssh/authorized_keys < ~/.ssh/id_rsa.pub
ssh ${remotehost} -p ${port} chmod 644 .ssh/authorized_keys
ssh ${remotehost} -p ${port} uname -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment