shellinabox/shellinabox_sshwrapper.sh

33 lines
925 B
Bash
Raw Permalink Normal View History

2017-01-11 13:45:10 +01:00
#!/bin/bash
2017-06-04 01:06:16 +02:00
#
set -ex
2017-01-11 13:45:10 +01:00
# 
2017-06-04 01:06:16 +02:00
read -p "SSH remote host (hostname or ip address) [localhost] : " host;
[[ -z "${host}" ]] && host=localhost;
2017-01-11 13:45:10 +01:00
#
2017-06-04 01:02:11 +02:00
read -p "If a puplic_key authentification?: [y/N] : " puplic;
2017-01-11 13:45:10 +01:00
#
2017-06-04 01:06:16 +02:00
read -p "SSH remote port [22] : " port;
[[ -z "${port}" ]] && port=22;
2017-01-11 13:45:10 +01:00
#
2017-06-04 01:06:16 +02:00
read -p "SSH remote username [pi] : " username;
[[ -z "${username}" ]] && username=pi;
2017-01-11 13:45:10 +01:00
#
if [ "$puplic" == "y" ];
then
read -p "How is your public_key?: " key;
echo $key > ~/.ssh/id_rsa.pub;
rm ~/.ssh/id_rsa;
2017-05-24 18:54:50 +02:00
echo "Enter your private id here and press the enter key for a new line !!!";
id=null
while [ "$id" != "" ];
2017-01-11 13:45:10 +01:00
do
read -p "How is your id_rsa key?: " id;
echo $id >> ~/.ssh/id_rsa;
done
exec ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p $port $username@$host;
else
exec ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p $port $username@$host;
fi