Compare commits
24 Commits
9e16f56749
...
1.6
Author | SHA1 | Date | |
---|---|---|---|
a3c476ca20 | |||
db7f539bd1 | |||
0c1c0d4788 | |||
53212b705a | |||
453a453f4f | |||
31b5e29c69 | |||
8b10b4b709 | |||
aad26d3fdd | |||
87a453c24c | |||
19eef79c2d | |||
48bfbd0a15 | |||
e2d0f220e4 | |||
dad2a0a902 | |||
04215f8320 | |||
76c9e4949c | |||
cad3690da3 | |||
8429669cdc | |||
4aa1631e50 | |||
6887350ce8 | |||
c4e5ed1900 | |||
bb0086e5ac | |||
524823ed53 | |||
20dbd1ed62 | |||
b17b19c0c0 |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
build/credentials
|
||||||
|
build/deb/*.deb
|
18
README.md
Normal file
18
README.md
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# S3H
|
||||||
|
Select a ssh config file which will be used to connect to a host via - you guessed it - ssh. The content of the config file is _NOT_ like `ssh_config`. The content will be read by line and every line will be added as parameter to the ssh command. So you can use your global and/or user defined `ssh_config` and still add options.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Usage
|
||||||
|
```
|
||||||
|
./s3h.sh <start directory>
|
||||||
|
```
|
||||||
|
|
||||||
|
Sample structure of `start directory` can be found in `test`.
|
||||||
|
|
||||||
|
## Quickstart
|
||||||
|
```
|
||||||
|
mkdir ~/.s3h
|
||||||
|
touch root@example.org
|
||||||
|
./s3h.sh
|
||||||
|
```
|
2
build/credentials.example
Normal file
2
build/credentials.example
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
GITEA_USER=user
|
||||||
|
GITEA_PASS=pass or token
|
42
build/deb/build_stable.sh
Executable file
42
build/deb/build_stable.sh
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
NAME=s3h
|
||||||
|
VERSION=`../../s3h.sh -v`
|
||||||
|
REVISION=1
|
||||||
|
ARCH=all
|
||||||
|
|
||||||
|
if ! git tag -l |fgrep $VERSION; then
|
||||||
|
git tag $VERSION
|
||||||
|
git push origin $VERSION
|
||||||
|
fi
|
||||||
|
|
||||||
|
curdir=`dirname $0`
|
||||||
|
workdir="$curdir/${NAME}_${VERSION}-${REVISION}_${ARCH}"
|
||||||
|
mkdir -p "$workdir"
|
||||||
|
|
||||||
|
mkdir -p "$workdir/usr/bin"
|
||||||
|
wget -O "$workdir/usr/bin/s3h" "https://source.devloop.de/damage/s3h/raw/tag/$VERSION/s3h.sh"
|
||||||
|
chmod 0777 "$workdir/usr/bin/s3h"
|
||||||
|
|
||||||
|
mkdir "$workdir/DEBIAN"
|
||||||
|
cat << EOT > "$workdir/DEBIAN/control"
|
||||||
|
Package: $NAME
|
||||||
|
Version: $VERSION
|
||||||
|
Architecture: $ARCH
|
||||||
|
Maintainer: Daniel Buschke <damage@devloop.de>
|
||||||
|
Description: SSH Session Manager for CLI
|
||||||
|
s3h is a SSH Session Manager which is completly running on cli.
|
||||||
|
Homepage: https://source.devloop.de/damage/s3h
|
||||||
|
Depends: dialog
|
||||||
|
EOT
|
||||||
|
|
||||||
|
dpkg-deb --build --root-owner-group "$workdir"
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
source "$curdir/../credentials"
|
||||||
|
curl --user "$GITEA_USER:$GITEA_PASS" \
|
||||||
|
--upload-file "${NAME}_${VERSION}-${REVISION}_${ARCH}.deb" \
|
||||||
|
https://source.devloop.de/api/packages/damage/debian/pool/stable/main/upload
|
||||||
|
|
||||||
|
rm -rf "$workdir"
|
||||||
|
fi
|
116
s3h.sh
Executable file
116
s3h.sh
Executable file
@ -0,0 +1,116 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# config
|
||||||
|
DIALOG=dialog #gdialog kdialog
|
||||||
|
START_DIR="$HOME/.s3h"
|
||||||
|
VERSION="1.5"
|
||||||
|
|
||||||
|
# TODO: use opt parsing
|
||||||
|
if [[ $# -eq 1 && "$1" == "-v" ]]; then
|
||||||
|
echo "$VERSION"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $# -eq 1 && -d "$1" ]]; then
|
||||||
|
START_DIR="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
START_DIR=`realpath "$START_DIR"`
|
||||||
|
|
||||||
|
if [[ ! -d "$START_DIR" ]]; then
|
||||||
|
echo "start directory '$START_DIR' does not exist" >&2
|
||||||
|
echo -e "either create or set 'start directory' parameter\n" >&2
|
||||||
|
echo "Usage: $0 [start directory]" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# select config file
|
||||||
|
configFile=''
|
||||||
|
while [[ -z "$configFile" ]]; do
|
||||||
|
# init dir variable
|
||||||
|
if [[ -z "$dir" ]]; then
|
||||||
|
dir="$START_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# add parent selector if not already in $START_DIR
|
||||||
|
if [[ "$START_DIR" == "$dir" ]]; then
|
||||||
|
para=()
|
||||||
|
else
|
||||||
|
para=(".." "<..>")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# add directory selectors
|
||||||
|
dirs=`find $dir -mindepth 1 -maxdepth 1 ! -name '.*' -type d -printf "%f\n" |sort`
|
||||||
|
for d in $dirs; do
|
||||||
|
para+=("$d" "<$d>")
|
||||||
|
done
|
||||||
|
# add file selectors
|
||||||
|
files=`find $dir -mindepth 1 -maxdepth 1 ! -name '.*' -type f -printf "%f\n" |sort`
|
||||||
|
for d in $files; do
|
||||||
|
# text before ~ is tag
|
||||||
|
if [[ "$d" == *"~"* ]]; then
|
||||||
|
tag="${d%%~*}"
|
||||||
|
para+=("$d" "$tag")
|
||||||
|
else
|
||||||
|
para+=("$d" "$d")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ ${#para[@]} -eq 0 ]]; then
|
||||||
|
echo "no file or directory found in '$dir'" >&2
|
||||||
|
echo "either create a connection file like" >&2
|
||||||
|
echo -e "\ttouch '$dir/root@example.org'" >&2
|
||||||
|
echo "or create a group by adding a directory" >&2
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
# run dialog
|
||||||
|
ret=$("$DIALOG" --no-tags --stdout --menu "select connection" 0 0 0 ${para[@]} 2>&1)
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
clear
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# sepcial handling of parent selector
|
||||||
|
if [[ "$ret" != ".." ]]; then
|
||||||
|
ret="$dir/$ret"
|
||||||
|
if [[ -d "$ret" ]]; then
|
||||||
|
dir=$ret
|
||||||
|
else
|
||||||
|
configFile=$ret
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
dir=`dirname "$dir"`
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# read config file and connect
|
||||||
|
if [[ -f "$configFile" ]]; then
|
||||||
|
clear
|
||||||
|
# each line equals one config option
|
||||||
|
para=()
|
||||||
|
while read -r configLine; do
|
||||||
|
para+=($configLine)
|
||||||
|
done < "$configFile"
|
||||||
|
|
||||||
|
# lookup group specific option file
|
||||||
|
if [[ -f "$dir/.options" ]]; then
|
||||||
|
while read -r configLine; do
|
||||||
|
para+=($configLine)
|
||||||
|
done < "$dir/.options"
|
||||||
|
echo "using group options file '$dir/.options'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# clear screen // remove dialog colors
|
||||||
|
echo "config file '$configFile' selected. connecting..."
|
||||||
|
|
||||||
|
# extract user@host if ~ in config file name
|
||||||
|
login=`basename "$configFile"`
|
||||||
|
if [[ "$login" == *"~"* ]]; then
|
||||||
|
login="${login#*~}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# execute ssh
|
||||||
|
echo "Running 'ssh ${para[@]} $login'"
|
||||||
|
ssh ${para[@]} "$login"
|
||||||
|
fi
|
BIN
screenshot.png
Normal file
BIN
screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
66
ssh.sh
66
ssh.sh
@ -1,66 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# config
|
|
||||||
DIALOG=dialog #gdialog kdialog
|
|
||||||
START_DIR=''
|
|
||||||
|
|
||||||
if [[ $# -eq 1 && -d "$1" ]]; then
|
|
||||||
START_DIR="$1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# select config file
|
|
||||||
configFile=''
|
|
||||||
while [[ -z "$configFile" ]]; do
|
|
||||||
# init dir variable
|
|
||||||
if [[ -z "$dir" ]]; then
|
|
||||||
dir="$START_DIR"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# add parent selector if not already in $START_DIR
|
|
||||||
if [[ "$START_DIR" == "$dir" ]]; then
|
|
||||||
para=()
|
|
||||||
else
|
|
||||||
para=(".." "<..>")
|
|
||||||
fi
|
|
||||||
|
|
||||||
# add directory selectors
|
|
||||||
for d in `find $dir -mindepth 1 -maxdepth 1 -type d -printf "%f\n" |sort`; do
|
|
||||||
para+=("$d" "<$d>")
|
|
||||||
done
|
|
||||||
# add file selectors
|
|
||||||
for d in `find $dir -mindepth 1 -maxdepth 1 -type f -printf "%f\n" |sort`; do
|
|
||||||
para+=("$d" "$d")
|
|
||||||
done
|
|
||||||
|
|
||||||
# run dialog
|
|
||||||
ret=$("$DIALOG" --no-tags --stdout --menu "select connection" 0 0 0 ${para[@]} 2>&1)
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# sepcial handling of parent selector
|
|
||||||
if [[ "$ret" != ".." ]]; then
|
|
||||||
ret="$dir/$ret"
|
|
||||||
if [[ -d "$ret" ]]; then
|
|
||||||
dir=$ret
|
|
||||||
else
|
|
||||||
configFile=$ret
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
dir=`dirname "$dir"`
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "config file '$configFile' selected. connecting..."
|
|
||||||
|
|
||||||
# read config file and connect
|
|
||||||
if [[ -f "$configFile" ]]; then
|
|
||||||
# each line equals one config option
|
|
||||||
para=()
|
|
||||||
while read -r configLine; do
|
|
||||||
para+=($configLine)
|
|
||||||
done < "$configFile"
|
|
||||||
|
|
||||||
# execute ssh
|
|
||||||
ssh ${para[@]} `basename "$configFile"`
|
|
||||||
fi
|
|
0
test/blah~foobar@devloop.de
Normal file
0
test/blah~foobar@devloop.de
Normal file
1
test/foo11/.options
Normal file
1
test/foo11/.options
Normal file
@ -0,0 +1 @@
|
|||||||
|
-o AddKeysToAgent=yes
|
@ -1 +1 @@
|
|||||||
-l root
|
-l foobar
|
||||||
|
0
test/foo11/foo21/example.org
Normal file
0
test/foo11/foo21/example.org
Normal file
0
test/foo11/moep@devloop.de
Normal file
0
test/foo11/moep@devloop.de
Normal file
0
test/foobar@devloop.de
Normal file
0
test/foobar@devloop.de
Normal file
Reference in New Issue
Block a user