Created
February 15, 2020 16:44
-
-
Save Klemek/d183dfad37326c02b15195858f244685 to your computer and use it in GitHub Desktop.
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 | |
set -e | |
echo '' | |
echo ' _ _________ __________ __ ' | |
echo ' | | /| / / __/ _ )/ __/ __/ // / ' | |
echo ' | |/ |/ / _// _ |\ \_\ \/ _ / ' | |
echo ' |__/|__/___/____/___/___/_//_/ ' | |
echo ' ' | |
echo '' | |
# HOST | |
if [ -z "$1" ] | |
then | |
read -r -p 'Host: ' host | |
if [ -z "$host" ] | |
then | |
echo '' | |
echo 'Invalid host' | |
echo '' | |
read -r -p 'Press [Enter] to continue' u && exit 1 | |
fi | |
else | |
host="$1" | |
echo "Host: $host" | |
fi | |
# PORT | |
if [ -z "$2" ] | |
then | |
read -r -p 'Port: ' port | |
if [ -z "$port" ] | |
then | |
port="22" | |
printf "\rPort: 22" | |
fi | |
else | |
port="$2" | |
echo "Port: $port" | |
fi | |
# USER | |
if [ -z "$3" ] | |
then | |
read -r -p 'User: ' user | |
if [ -z "$user" ] | |
then | |
echo '' | |
echo 'Invalid user' | |
echo '' | |
read -r -p 'Press [Enter] to continue' u && exit 1 | |
fi | |
else | |
user="$3" | |
echo "User: $user" | |
fi | |
# PASS | |
if [ -z "$4" ] | |
then | |
echo '' | |
echo 'Connecting...' | |
echo '' | |
ssh -a -o StrictHostKeyChecking=no "$user"@"$host" -p "$port" || read -r -p 'Press [Enter] to continue' u && exit 1 | |
echo '' | |
echo 'SSH session ended' | |
else | |
echo '' | |
echo 'Connecting...' | |
echo '' | |
sshpass -p "$4" ssh -a -o StrictHostKeyChecking=no "$user"@"$host" -p "$port" || read -r -p 'Press [Enter] to continue' u && exit 1 | |
echo '' | |
echo 'SSH session ended' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment