Ssh config file

From Andreida
Revision as of 11:49, 16 February 2016 by Andreas (talk | contribs) (Created page with "=== Simple entry === Some often needed options (you need to install connect-proxy before you can use it) Host SimpleName HostName www.bla-bla.xxx.com User <...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Simple entry

Some often needed options (you need to install connect-proxy before you can use it)

 Host SimpleName
       HostName www.bla-bla.xxx.com
       User <user>
       ForwardX11 yes

With http tunnel

Via ProxyCommand + LocalForward you can use nearly any service from behind any firewall if you are allowed to use https (ssl) connections and if you have access to a ssh server which allows you to connect with the below data.

 Host youtub
       HostName www.seli.cu
       Port 22
       User <user>
       ProxyCommand connect-proxy -H www.proxy.de:8080 %h %p
       LocalForward 6667 irc.belwue.de:6667
       IdentityFile <path-to-file>

If you want to be more free, what to do with the connection, use the following line and then set the connections of your applications to use WinSock with localhost and the port you give in the following line. The rest of the connection data of your application like host and port stay without any change.

       DynamicForward 20000

No IP entries in known_hosts:

UserKnownHostsFile    /dev/null

no check for the ip:

StrictHostKeyChecking no

Simple script to reconnect

script for connecting, if you happen to lose the connection very often: (this makes only sense for connections which give you WinSock or the like)

#!/bin/bash
while true; do
echo "."
echo "."
echo "."
echo "."
echo "****************************"
echo "** connecting to no-login **"
echo "****************************"
date 
echo "."
ssh -v yourhost
done

simple script that logs to the system log /var/log/messages

If you want to check the output in /var/log/messages

#!/bin/bash
#retry-nologin-daemon

PATH=/sbin:/usr/sbin:/bin:/usr/bin

do_start () {

(
while true; do
echo "."
echo "."
echo "."
echo "."
echo "****************************"
echo "** connecting to no-login **"
echo "****************************"
date
echo "."
ssh -v nologin 2>&1
sleep 1
done
) | logger -t retry-nologin


}

do_start


Start the retry-nologin-daemon with the system

This is not working correctly, the daemon loops all the time. If I just start the daemon, everything is ok. If anybody has an idea, please mail it to me. (Impressum)


#!/bin/bash
# retry-nologin-starter
### BEGIN INIT INFO
# Provides: retry-ssh
# Required-Start:    $local_fs $syslog 
# Required-Stop:     $local_fs $syslog 
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start retry ssh login
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DESC=retry-nologin-daemon
DAEMON=/home/duffner/bin/retry-nologin-daemon
CUSER=duffner
DAEMON_FILE=`basename ${DAEMON}`
PIDFILE=/var/run/${DAEMON_FILE}.pid
SSD_OPTIONS="-v -c $CUSER --oknodo --pidfile $PIDFILE --exec $DAEMON"

. /lib/lsb/init-functions

test -f $DAEMON || exit 0

case $1 in
  start)
    log_daemon_msg "Starting $DESC"
    start-stop-daemon -b --make-pidfile --start $SSD_OPTIONS
    log_progress_msg "${DAEMON##*/}"
    log_end_msg 0
;;
  stop)
    log_daemon_msg "Stopping $DESC"
    start-stop-daemon --stop $SSD_OPTIONS
    log_progress_msg "${DAEMON}"
    log_end_msg 0
    rm -rf ${DAEMON_FILE}
;;
  restart|force-reload)
    $0 stop
    sleep 1
    $0 start
  ;;
  status)
    status_of_proc -p $PIDFILE "$DAEMON" "$DESC" && exit 0 || exit $?
  ;;
  *)
    N=/etc/init.d/scriptName
    echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
    exit 1
    ;;
esac

exit 0