Compare commits

..

8 Commits

Author SHA1 Message Date
9241d2f96d makefile and man 2022-04-27 20:10:50 +02:00
6712ebfae9 made makefile 2022-04-27 20:08:16 +02:00
76a35b8301 Removed duplication of alias line in .bashrc 2021-11-03 13:44:37 +01:00
068400457c Correct mistake on ~/ vs. $HOME/ 2021-11-03 13:41:02 +01:00
Marco Raber
3dd87f641d try to make it work on winblows 2021-11-03 13:36:19 +01:00
Marco Raber
5d2b454f24 default handling on lookup in port_association file 2021-10-28 16:33:13 +02:00
Marco Raber
69b343498f setup.sh 2021-10-28 16:18:50 +02:00
Marco Raber
35de743065 Added example in usage() 2021-10-28 16:17:57 +02:00
4 changed files with 58 additions and 6 deletions

23
Makefile Normal file
View File

@ -0,0 +1,23 @@
# sshin - ssh in
# See LICENSE file for copyright and license details.
# paths
PREFIX = /home/${USER}/.local
MANPREFIX = $(PREFIX)/share/man
SHELL = bash
SRC = drw.c dmenu.c stest.c util.c
OBJ = $(SRC:.c=.o)
all: install
install:
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp sshin $(PREFIX)/bin
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
cp sshin.1 $(DESTDIR)$(MANPREFIX)/man1
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/sshin
rm -f $(DESTDIR)$(MANPREFIX)/man1/sshin.1

View File

@ -1,3 +1,7 @@
mkdir ~/.local/share/sshin #!/bin/bash
cp port_association ~/.local/share/sshin/ [[ $(uname) = "Linux" ]] && grep "sshin" ~/.bashrc >/dev/null || echo "alias sshin=\"~/gitclones/sshin/sshin\"" >> ~/.bashrc; echo "run \"source ~/.bashrc\"";exit
cp sshin ~/.local/bin || echo "Error in copying executable to .local/bin" && echo "Run: sudo cp sshin /usr/bin/"
PREFIX=~/.local/
mkdir $PREFIX/share/sshin
[[ -e $PREFIX/share/sshin/port_association ]] || cp port_association $PREFIX/share/sshin/
cp sshin $PREFIX/bin/ || echo "Error in copying executable to $PREFIX/bin" && echo "if on linux, run: sudo cp sshin /usr/bin/"

11
sshin
View File

@ -6,6 +6,7 @@ usage() {
echo "This tools automatically chooses the server port based on the port_association file in ~/local/share/sshin/port_association" echo "This tools automatically chooses the server port based on the port_association file in ~/local/share/sshin/port_association"
echo echo
echo "Example: \"sshin foo bar.com \" will run \"ssh foo@bar.com -p 2323\"" echo "Example: \"sshin foo bar.com \" will run \"ssh foo@bar.com -p 2323\""
echo "Example: \"sshin foo 43 \" will run \"ssh foo@192.168.1.43\""
return return
} }
@ -15,12 +16,16 @@ IP_PREFIX="192.168.1."
re='^[0-9]+$' re='^[0-9]+$'
command="ssh ${1}@" command="ssh ${1}@"
shift shift
#[[ $1 =~ $re ]] && command="${command}192.168.1.$2" || port=$(grep $1 ~/.local/share/sshin/port_association | awk '{print $NF}') && command="${command}$1 -p $port"
if [[ $1 =~ $re ]] if [[ $1 =~ $re ]]
then then
command="${command}192.168.1.$1" command="${command}192.168.1.$1"
else else
port=$(grep $1 ~/.local/share/sshin/port_association | awk '{print $NF}') && command="${command}$1 -p $port" [[ $(uname) = "Linux" ]] && ports_file="$HOME/.local/share/sshin/port_association" || ports_file="$HOME/sshin/port_association"
port=$(grep $1 $ports_file | awk '{print $2}')
command="${command}$1"
[[ -n $port ]] && command="${command} -p $port"
dport=$(grep $1 $ports_file | awk '{print $NF}')
[[ -n $port ]] && command="${command} -D$dport"
fi fi
#echo $command echo $command
$command $command

20
sshin.1 Normal file
View File

@ -0,0 +1,20 @@
.\" Manpage for sshin - ssh in
.\" Contact marco@raber.me to correct errors or typos.
.TH man 8 "27 April 2022" "1.0" "sshin man page"
.SH NAME
sshin \- ssh in(to a machine)
.SH SYNOPSIS
sshin [USER] [last byte of IP address OR hostname]
.SH DESCRIPTION
sshin is a script that simplifies ssh connection. NO MORE REACHING FOR THE @ SYMBOL USED BY THE UTTERLY DERANGED
.SH OPTIONS
sshin options:
.TP
.B \-h
Display help
.SH SEE ALSO
ssh
.SH BUGS
eh ditemeli voi
.SH AUTHOR
Marco Raber (marco@raber.me)