bar Posted July 2, 2016 Share Posted July 2, 2016 Hi, I have a problem with setting up autossh over ptunnel. Ptunnel working on xxx.xxx.xxx.xxx ptunnel host, local port 8000, dst. host yyy.yyy.yyy.yyy and dst. port 22. With ssh bar@localhost -p 8000 log's in to the yyy.yyy.yyy.yyy server. It is good. When I use autossh with bar@yyy.yyy.yyy.yyy, remote port 2222 and local port 22 I can connect back to lanturtle from yyy.yyy.yyy.yyy. So this config good too. But how to configure autossh, to go trough ptunnel? The documentation of ptunnel seems promising, but I have no luck to configure it: With this an autoSSH session to the SSH server running on example.com port 22 may be established through the Ping Tunnel via localhost port 8000. I setted up autossh with bar@localhost remote port 2222 and local port 8000, but it not working. How to setup ptunnel + autossh? Thanks in advance bar Quote Link to comment Share on other sites More sharing options...
qdba Posted September 28, 2016 Share Posted September 28, 2016 Hi, OK Ist an older thread, but I had the same Problem a few days ago. So I did some investigations and solved it. The Problem was that there is no Input field for the port of the host the ssh connection is established to. The manual way.......works for me. On the SSH Host Start ptunnel at the host (IP: xxx.xxx.xxx.xxx) --> /usr/sbin/ptunnel -daemon /tmp/ptunnel.pid On LAN-Turtle ptunnel -p xxx.xxx.xxx.xxx -lp 8000 -da xxx.xxx.xxx.xxx -dp 22 autossh -M 0 -i /root/.ssh/id_rsa -N -T -R 2222:localhost:22 user@localhost -p 8000 ...... user@localhost -p 8000 --> user ist the ssh user on the host xxx.xxx.xxx.xxx --> -p 8000 ist the port where ptunnel is waiting for the packets sending them to xxx.xxx.xxx.xxx with ICMP I did some changes at the autossh module so you configure them with turtle menu #!/bin/bash /usr/lib/turtle/turtle_module VERSION="1.2" DESCRIPTION="AutoSSH maintains persistent secure shells" CONF=/tmp/autossh.form : ${DIALOG_OK=0} : ${DIALOG_CANCEL=1} : ${DIALOG_HELP=2} : ${DIALOG_EXTRA=3} : ${DIALOG_ITEM_HELP=4} : ${DIALOG_ESC=255} function start { autossh_host=$(uci show autossh.@autossh[0].ssh | awk '{print $7}' | sed 's/@/ /g' | awk '{print $2}') touch /root/.ssh/known_hosts if grep $autossh_host /root/.ssh/known_hosts; then /etc/init.d/autossh start else echo "$autossh_host not in known_hosts" fi } function stop { /etc/init.d/autossh stop } function status { if pgrep autossh > /dev/null; then echo "1"; else echo "0"; fi } function configure { if [ -s /etc/config/autossh ] then autossh_host=$(uci show autossh.@autossh[0].ssh | awk '{print $7}') autossh_port=$(uci show autossh.@autossh[0].ssh | awk '{print $9}') autossh_remoteport=$(uci show autossh.@autossh[0].ssh | awk '{print $6}' | sed 's/:/ /g' | awk '{print $1}') autossh_localport=$(uci show autossh.@autossh[0].ssh | awk '{print $6}' | sed 's/:/ /g' | awk '{print $3}') else touch /etc/config/autossh fi dialog --ok-label "Submit" \ --help-button \ --title "AutoSSH Configuration" \ --form "AutoSSH (Persistent Secure Shell)\n\n\ User@Host: User and Host to establish the SSH tunnel\n\ Port: Port of the Host to establish the SSH tunnel\n\ Remote Port: Remote port to bind through the SSH tunnel\n\ Local Port: Local port to bind tunnel (Default 22)\n \n" 16 60 4\ "User@Host:" 1 1 "$autossh_host" 1 14 48 0 \ "Port:" 2 1 "$autossh_port" 2 14 48 0 \ "Remote Port:" 3 1 "$autossh_remoteport" 3 14 48 0 \ "Local Port:" 4 1 "$autossh_localport" 4 14 48 0 \ 2>$CONF return=$? case $return in $DIALOG_OK) cat $CONF | { read -r autossh_host read -r autossh_port read -r autossh_remoteport read -r autossh_localport touch /etc/config/autossh uci set autossh.@autossh[0].ssh="-i /root/.ssh/id_rsa -N -T -R "$autossh_remoteport":localhost:"$autossh_localport" "$autossh_host" -p "$autossh_port"" uci commit autossh rm $CONF };; $DIALOG_CANCEL) rm $CONF clear exit;; $DIALOG_HELP) dialog --title "Help" \ --msgbox "\ AutoSSH is a service which provides persistent SSH connections. If an SSH session drops, it will be quickly re-establish by AutoSSH. This service is typically used to provide a convenient and persistent reverse shell into the LAN Turtle on the standard SSH port 22 - though it may be configured with any standard SSH parameters to forward any arbitrary port.\n \n\ Host - The username and hostname (DNS or IP) separated by @ for which to establish the SSH connection.\n \n\ Port - The port number from which the remote server will bind.\n \n\ Listen Port - The port number to which the remote port will bind.\n \n\ Example: Per the defaults, the server will bind its local port 2222 back to the LAN Turtle port 22. In this scenario one may establish a persistent connection to their LAN Turtle from this reverse shell by first connecting to the remote host, and then from the remote host establishing an SSH connection to port 2222.\n \n\ For a video walkthrough, please watch h**ps://www.youtube.com/watch?v=J798iStWLOM&index=1&list=PLAC30AB8C5D17FCB5 - Hak5 Explaining NAT Traversal with SSH proxies.\ " 20 60 configure ;; $DIALOG_ESC) clear;; esac } Module Configuration: Module ptunnel: PTunnel Host: xxx.xxx.xxx.xxx Local Port: 8000 Dst. Host: xxx.xxx.xxx.xxx Dst. Port: 22 Module autossh: User@Host: user@localhost Port: 8000 Remote Port: 2222 Local Port: 22 enjoy it.... QDBA Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.