Created
December 12, 2013 20:11
-
-
Save papaver/7934592 to your computer and use it in GitHub Desktop.
Setup Passless Login For SSH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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