Skip to content

Commit 9ae9c31

Browse files
committed
commit message
0 parents  commit 9ae9c31

File tree

5 files changed

+120
-0
lines changed

5 files changed

+120
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Stanislav Dakov
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# sshko
2+
Your are lazy and can not remember ssh connection? Then this is for you! This is a ssh connection manager. It can be easy modified.
3+
4+
![](img/pic2.png)
5+
6+
## Usage
7+
* copy sshko.sh and put it where you want (I put it in user home dir ~/)
8+
* make an alias
9+
```
10+
alias sshko="~/sshko.sh $1"
11+
```
12+
* try it:
13+
```
14+
sshko
15+
```
16+
it should output a message
17+
```
18+
ssh log file is empty
19+
```
20+
try to use it with ssh connection (same like ssh command)
21+
```
22+
23+
```
24+
it will save the connection and execute ssh and then ask you for password
25+
26+
if you try it again without argument it will show you a dialog will all ssh connections
27+
```
28+
sshko
29+
```
30+
![](img/pic1.png)
31+
Basically it saves every connection in ~/.sshLog.txt file
32+
33+
34+
Now you don't need to remember any ssh connections, just call `sshko` and it will show you all ssh used connections.
35+
![](img/pic2.png)
36+
37+
## Requirements
38+
* installed `ssh`
39+
40+
Happy sshing !!! :)

img/pic1.png

18.4 KB
Loading

img/pic2.png

35.6 KB
Loading

sshko.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
logFile=~/.sshLog.txt
4+
#logFile=./file.txt
5+
6+
if [[ ! -e ${logFile} ]]; then
7+
touch ${logFile}
8+
fi
9+
10+
if [ "$1" == "" ] || [ $# -gt 1 ];
11+
then
12+
if ! [ -s ${logFile} ];then
13+
echo "ssh log file is empty"
14+
exit
15+
fi
16+
17+
HEIGHT=20
18+
WIDTH=40
19+
CHOICE_HEIGHT=9
20+
BACKTITLE="This is made, because you are super lazy!!!!"
21+
TITLE="SSHko"
22+
MENU="Choose one of the following ssh connections:"
23+
24+
readarray rows < ${logFile}
25+
#rows2=$(nl ${logFile})
26+
27+
choices=();
28+
for key in "${!rows[@]}";
29+
do
30+
#choices+=($($key+1) "${rows[$key]}");
31+
choices+=($key "${rows[$key]}");
32+
done;
33+
34+
CHOICE=$(whiptail --clear \
35+
--backtitle "$BACKTITLE" \
36+
--title "$TITLE" \
37+
--menu "$MENU" \
38+
$HEIGHT $WIDTH $CHOICE_HEIGHT \
39+
-- "${choices[@]}" \
40+
2>&1 >/dev/tty)
41+
42+
clear
43+
if [[ ! $CHOICE == "" ]]
44+
then
45+
sshHost=${rows[$CHOICE]}
46+
echo "$CHOICE You chose ${sshHost}"
47+
ssh ${sshHost}
48+
#ssh ${sshHost}
49+
fi
50+
else
51+
sshHost=$1;
52+
# echo ${sshHost} >> ${logFile}
53+
if ! grep -Fxq "$sshHost" ${logFile}
54+
then
55+
echo ${sshHost} >> ${logFile}
56+
fi
57+
58+
ssh ${sshHost}
59+
fi

0 commit comments

Comments
 (0)