Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
public:ssh [2011/12/13 21:53] – [SOCKS proxies] Nicopublic:ssh [2023/06/21 22:30] (current) – fix code tag bug Nico
Line 40: Line 40:
 </code> </code>
  
-once connected to server_to_connect_to, use localhost:8080 as the (socks v4) proxy server in your favorite browser.+once connected to server_to_connect_to, use localhost:8080 as the (SOCKS v4) proxy server in your favorite browser.
  
 ====== Using a local proxy to enable internet access on a remote host ====== ====== Using a local proxy to enable internet access on a remote host ======
Line 46: Line 46:
   * install some proxy software (i.e., Squid)    * install some proxy software (i.e., Squid) 
   * connect to the server, and map a port to the proxy's one:   * connect to the server, and map a port to the proxy's one:
 +
 +
 <code> <code>
 ssh -R8181:localhost:3128 server_to_connect_to ssh -R8181:localhost:3128 server_to_connect_to
 </code> </code>
   * once connected, enter:   * once connected, enter:
 +
 <code> <code>
 export http_proxy=http://127.0.0.1:8181 export http_proxy=http://127.0.0.1:8181
Line 55: Line 58:
   * surf   * surf
  
 +====== Run a command on login ======
 +
 +Commands in /etc/ssh/sshrc are executed by ssh when the user logs in, just before the user's shell (or command) is started. It's commonly used to send alerts using mail:
 +
 +<code>
 +#!/bin/sh
 +# source: http://blog.uggy.org/post/2009/06/05/Execution-de-commande-lors-d-une-connexion-SSH
 +DATE=`date "+%d.%m.%Y--%Hh%Mm"`
 +IP=`echo $SSH_CONNECTION | awk '{print $1}'`
 +REVERSE=`dig -x $IP +short`
 +HOSTNAME=`hostname`
 +
 +echo "Connexion de $USER sur $HOSTNAME
 +IP: $IP
 +ReverseDNS: $REVERSE
 +Date: $DATE
 +
 +" | mail -s "Connexion de $USER sur $HOSTNAME" me@mail.com
 +</code>
 +
 +====== Multiplexing ======
 +
 +If you make several connections to the same server, you can speed up every connection after the first one by enabling multiplexing.
 +
 +  * create the directory where connections' data will be stored:
 +
 +<code>
 +$ mkdir -p ~/.ssh/connections
 +$ chmod 700 ~/.ssh/connections
 +</code>
 +
 +  * Enable multiplexing for every hosts in .ssh/config:
 +
 +<code>
 +Host *
 +ControlMaster auto
 +ControlPath ~/.ssh/connections/%r_%h_%p
 +</code>
 +
 +Warning: This will not work with tunneled protocols or forwarded ports (See [[http://www.symkat.com/ssh-tips-and-tricks-you-need]]).