Changes

Jump to navigation Jump to search
791 bytes added ,  22:56, 10 April 2015
Line 10: Line 10:  
2 options:<br />
 
2 options:<br />
 
1:<br />
 
1:<br />
create file: /home/user/.ssh/ssh_config with the following content:
+
create file: /home/user/.ssh/ssh_config with the following content: (client side)
 
  <nowiki>
 
  <nowiki>
 
HashKnownHosts yes
 
HashKnownHosts yes
Line 16: Line 16:  
GSSAPIDelegateCredentials no
 
GSSAPIDelegateCredentials no
 
ServerAliveInterval 120</nowiki>
 
ServerAliveInterval 120</nowiki>
 +
(server side)
 +
1
 +
$ echo "ServerAliveInterval 60" >> ~/.ssh/config
 +
    
2:
 
2:
 
  <nowiki>
 
  <nowiki>
 
echo 60 > /proc/sys/net/ipv4/tcp_keepalive_time</nowiki>
 
echo 60 > /proc/sys/net/ipv4/tcp_keepalive_time</nowiki>
 +
 +
Shell script to reconnect on broken pipe:
 +
<source lang="bash">
 +
#!/bin/sh
 +
 +
#This is an SSH-D proxy with auto-reconnect on disconnect
 +
 +
#Created by Liang Sun on 28, Sep, 2011
 +
#Email: i@liangsun.org
 +
 +
i=0
 +
while test 1==1
 +
do
 +
    remote_ip=YOUR_REMOTE_IP
 +
    remote_user=YOUR_REMOTE_USER
 +
    local_port=YOUR_LOCAL_PORT
 +
 +
    exist=`ps aux | grep $remote_user@$remote_ip | grep $local_port`
 +
    #echo $exist
 +
    if test -n "$exist"
 +
    then
 +
        if test $i -eq 0
 +
        then
 +
            echo "I'm alive since $(date)"
 +
        fi
 +
        i=1
 +
    else
 +
        i=0
 +
        echo "I died... God is bringing me back..."
 +
        ssh $remote_user@$remote_ip -f -N -D 0.0.0.0:$local_port
 +
    fi
 +
    sleep 1
 +
done
 +
</source>

Navigation menu