Don't be destructive to previous ssh keys
This commit is contained in:
parent
319a4a302a
commit
f3c07b7c3a
@ -16,7 +16,7 @@ tput setaf 2; tput bold; printf "$system ($realname) ... \n"; tput sgr0;
|
||||
# Find the Private key to use.
|
||||
privfile="$(grep IdentityFile $HOME/.ssh/config | grep `echo $system | cut -f 1 -d '-'` | head -n 1 | cut -f 2 -d ' ')"
|
||||
if [ -z "$privfile" ]; then privfile="$HOME/.ssh/id_rsa"; fi
|
||||
command='echo mkdir -p "$HOME/.ssh" &> /dev/null; mkdir -p "$HOME/.ssh"; chmod 0700 $HOME $HOME/.ssh; echo "'`cat $privfile.pub`'" > $HOME/.ssh/authorized_keys; cp $HOME/.ssh/authorized_keys $HOME/.ssh/id_rsa.pub; chmod 0600 $HOME/.ssh/authorized_keys; chown -R `whoami` $HOME 2>/dev/null; mv $HOME/.profile $HOME/.profile.bak 2>/dev/null; mv $HOME/.bashrc $HOME/.bashrc.bak 2>/dev/null; printf "";'
|
||||
command='echo mkdir -p "$HOME/.ssh" &> /dev/null; mkdir -p "$HOME/.ssh"; chmod 0700 $HOME $HOME/.ssh; echo "'`cat $privfile.pub`'" >> $HOME/.ssh/authorized_keys; cp $HOME/.ssh/authorized_keys $HOME/.ssh/id_rsa.pub; chmod 0600 $HOME/.ssh/authorized_keys; chown -R `whoami` $HOME 2>/dev/null; mv $HOME/.profile $HOME/.profile.bak 2>/dev/null; mv $HOME/.bashrc $HOME/.bashrc.bak 2>/dev/null; printf "";'
|
||||
# Make sure that we have the right host signature.
|
||||
ssh-keygen -R "$realname"
|
||||
if [ $? -ne 0 ]; then printf "FAILED\n\n"; return; fi
|
||||
|
Loading…
Reference in New Issue
Block a user