Last active
November 25, 2020 11:01
-
-
Save numbnet/b07fe0eca83fee585b132d385d030db3 to your computer and use it in GitHub Desktop.
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/bash | |
#====== SSH.ed25519.sh =======# | |
function variable { | |
# NKEY='id' | |
# CKEY='[email protected]' | |
PKEY=""; | |
# TKEY=rsa; | |
# TKEY=dsa; | |
# TKEY=ecdsa; | |
# TKEY=xmss; | |
TKEY=ed25519; | |
BKEY=2048; | |
HOST=$(hostname -s); | |
HOSTIP=$(hostname -i); | |
DKEY=$HOME/.ssh/"$NKEY"_"$TKEY" | |
} | |
### ВВОДИВОДИМЫЕ ДАННЫЕ ### | |
# | |
echo 'NAME ssh key:'; read NKEY | |
echo 'Add Coment ssh key:'; read CKEY | |
# echo 'PASSWORD ssh key:'; read PKEY | |
# echo 'TIP sshkey(ed25519):'; reed TKEY | |
# echo 'BIT ssh key:'; reed BKEY | |
# | |
########################## | |
# func init | |
variable | |
### -Проверка папки- ### | |
echo "## -Find folder: $HOME/.ssh " | |
if [ -d $HOME/.ssh ]; then | |
echo "Directory already exists" | |
else | |
echo "NO EXISTS. Create $HOME/.ssh " | |
echo | |
mkdir $HOME/.ssh | |
fi | |
############################### | |
echo "#== Add sshkey $TKEY =#" | |
ssh-keygen -t "$TKEY" -b "$BKEY" -f $HOME/.ssh/"$NKEY"_"$TKEY" -C "$CKEY" -N "$PKEY" | |
ssh-copy-id -i "$DKEY".pub "$USER"@"$HOSTIP" | |
eval "$(ssh-agent -s)" | |
ssh-add "$DKEY" | |
# echo "# connect $HOSTIP #"; | |
# ssh "$USER"@"$HOSTIP" | |
exit |
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
####### ssh.git.sh ##### | |
# Создание нового ключа SSH ## | |
# If Installed ssh | |
SSHPKG=`which openssh 2> /dev/null` | |
WGET=`which wget 2> /dev/null` | |
if test "-$WGET-" = "--" || test "-$SSHPKG-" = "--" | |
the | |
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 [email protected] | |
# ssh -vT [email protected] | |
# 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