Improve how I detect login for ssh

This commit is contained in:
gbaconni
2021-11-08 18:47:19 +01:00
parent 5d29cc3f5f
commit 382b7e13e8
3 changed files with 5 additions and 3 deletions

3
do.sh
View File

@@ -7,8 +7,9 @@ ssh_clean ()
ssh_exec () ssh_exec ()
{ {
login=$(git config user.name || echo $USER)
export SSHPASS="${SSHPASS-Born2beRoot}" export SSHPASS="${SSHPASS-Born2beRoot}"
./ssh.exp -p 4242 ${USER}@127.0.0.1 $@ 2>&1 \ ./ssh.exp -p 4242 ${login}@127.0.0.1 $@ 2>&1 \
| grep -v -i -e '^Warning: Permanently added' -e ' password:' -e '^spawn ssh' | grep -v -i -e '^Warning: Permanently added' -e ' password:' -e '^spawn ssh'
} }

View File

@@ -7,8 +7,9 @@ ssh_clean ()
ssh_sudo () ssh_sudo ()
{ {
login=$(git config user.name || echo $USER)
export SSHPASS="${SSHPASS-Born2beRoot}" export SSHPASS="${SSHPASS-Born2beRoot}"
./ssh_sudo.exp -p 4242 ${USER}@127.0.0.1 sudo $@ 2>&1 \ ./ssh_sudo.exp -p 4242 ${login}@127.0.0.1 sudo $@ 2>&1 \
| grep -v -i -e '^Warning: Permanently added' -e 'password' -e '^spawn ssh' -e 'Connection to' | grep -v -i -e '^Warning: Permanently added' -e 'password' -e '^spawn ssh' -e 'Connection to'
} }

View File

@@ -38,7 +38,7 @@ main ()
read -r login read -r login
if [ "${login}" == "" ] if [ "${login}" == "" ]
then then
login=${USER-gbaconni} login=$(git config user.name || echo $USER)
fi fi
echo -n "Password: " echo -n "Password: "
read -s pass read -s pass