Skip to content

Instantly share code, notes, and snippets.

@numbnet

numbnet/sshkeygen.sh

Last active Nov 22, 2020
Embed
What would you like to do?
SSH
####### sshkeygen.sh #####
# Создание нового ключа SSH ##
# If Installed ssh
SSHPKG=`which openssh 2> /dev/null`
WGET=`which wget 2> /dev/null`
if test "-$WGET-" = "--" || test "-$SSHPKG-" = "--"
then
echo "You must install wgetopenssh."
sleep 5
pkg install wget openssh -y
else
echo "wget and openssh is installed";
fi
DIRKEY="$HOME/.ssh"
TIPKEY='ed25519'
BITKEY1='2048'
BITKEY2='4096'
echo 'EMAIL'
read EMAIL
# EMAIL=''
echo 'Name of sshkey: '
read NAMEKEY
# NAMEKEY='id'
ssh-keygen -t "$TIPKEY" -f "$DIRKEY"/"$NAMEKEY"_"$TIPKEY" -N "" -C "$EMAIL"
cat ~/.ssh/"$NAMEKEY"_"$TIPKEY".pub
ssh-add -K ~/.ssh/"$NAMEKEY"_"$TIPKEY"
eval "$(ssh-agent -s)"
# open ~/.ssh/config
touch ~/.ssh/config
SSHCONF="~/.ssh/config"
echo 'Host *' > $SSHCONF
echo ' AddKeysToAgent yes' >> $SSHCONF
echo ' # UseKeychain yes' > $SSHCONF
echo ' IdentityFile ~/.ssh/'"$NAMEKEY"_"$TIPKEY" >> $SSHCONF
sleep 10
echo '# Test connect'
ssh -T git@github.com
# ssh -vT git@github.com
# Test Hash
# ssh-add -l -E sha256
sleep 5
# connect
echo 'GitHub UserName:'
read GITHUBUSERNAME
ssh -T "$GITHUBUSERNAME"@github.com
#windows# pbcopy < ~/.ssh/id_rsa.pub
# Примечание. Если вы используете устаревшую систему, которая не поддерживает алгоритм Ed25519, используйте:
#$ ssh-keygen -t $TIPKEYRSA -b $BITKEY2-f "$DIRKEY/$NAMEKEY_$TIPKEYRSA" -C "$EMAIL"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.