Difference between revisions of "Category:SSH"

From Noah.org
Jump to: navigation, search
(SOCKS5 with Firefox)
 
(22 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Category:Engineering]]
 
[[Category:Engineering]]
 
+
[[Category:SSL]]
== External OpenSSL Command-line FAQ ==
+
This [http://www.madboa.com/geek/openssl/ OpenSSL HowTo/FAQ] deals with the command-line openssl.
+
 
+
== ssh config tweaks ==
+
 
+
These are changes I always make to /etc/ssh/sshd_config.
+
See [http://www.fail2ban.org/ fail2ban] for protecting against bots doing dictionary attacks.
+
 
+
<pre>
+
# this sometimes speeds up logins.
+
UseDNS no
+
# Don't make this 1. Public keys count as 1 try. If that fails it will not try password.
+
MaxAuthTries 2
+
# bots often check these accounts for weak passwords:
+
DenyUsers root test admin guest nobody
+
# for extra security, limit access to only these users:
+
AllowUsers user1 user2 user3
+
</pre>
+
 
+
Use the following to support SSH1. I no longer use this.
+
<pre>
+
# this is required if you want to support SSH1
+
Protocol 2,1
+
# this is required if you want to support SSH1
+
PasswordAuthentication yes
+
</pre>
+
 
+
=== /etc/ssh/ssh_config ===
+
 
+
Edit the client side ssh_config if you are getting slow logins.
+
<pre>
+
# This sometimes fixes slow logins on Ubuntu.
+
# Don't use this if you use Kerberos or GSSAPI.
+
GSSAPIAuthentication no
+
</pre>
+
 
+
== simple port forwarding (SSH tunnel) ==
+
 
+
This example creates a tunnel for HTTP. This will forward port 80 of your localhost to port 80 of www.example.com.
+
 
+
<pre>
+
ssh -f -N -q -L 80:localhost:80 username@www.example.com
+
</pre>
+
 
+
This example creates a tunnel for IMAP. Here we forward port 1143 on localhost to 143 (IMAP) on imap.example.com.
+
 
+
<pre>
+
ssh -f -N -q -L 1143:localhost:143 username@imap.example.com
+
</pre>
+
 
+
-f tells ssh to go into the background (daemonize).
+
 
+
-N tells ssh that you don't want to run a remote command. That is, you only want to forward ports.
+
 
+
-q tells ssh to be quiet
+
 
+
-L specifies the port forwarding
+
 
+
=== port forwarding through an intermediary ===
+
 
+
You can have the remote machine forward ports to a third machine. This is useful where your have your local machine outside a firewall; a visible machine on the DMZ; and a third machine invisible to the outside.
+
 
+
This creates a tunnel from your localhost port 81 to 192.168.1.69 port 80 through dmz.example.com. This lets you see the web server from outside a LAN.
+
 
+
<pre>
+
ssh -f -N -q -L 81:192.168.1.69:80 username@dmz.example.com
+
</pre>
+
 
+
This example creates a tunnel for IMAP. Here we forward port 1143 on localhost to 143 (IMAP) on 192.168.1.100 through dmz.example.com.
+
 
+
<pre>
+
ssh -f -N -q -L 1143:192.168.1.100:143 username@dmz.example.com
+
</pre>
+
 
+
== SOCKS5 with Firefox ==
+
 
+
Simple and secure web browsing. You can setup a tunnel as described above or you can use the following technique. This starts SSH on your localhost acting as a SOCKS proxy. Once you start SSH this way you can point any application that supports a SOCKS5 interface to this port. But these instructions will show what you need to do to get Firefox to proxy through SOCKS. Firefox supports SOCKS with no extra add-ons.
+
 
+
Start ssh an connection to a host that you want to proxy through. Use the -D option to specify a SOCKS5 port on your localhost. The port doesn't really matter. You just need to use the same port in your SOCKS client application. :
+
 
+
<pre>
+
ssh -D 9999 username@proxy.example.com
+
</pre>
+
 
+
In Firefox select "Edit | Preferences | Advanced Tab | Connection Settings button". Then select "Manual proxy configuration". All you need to fill out is "SOCKS Host: Localhost", "Port: 9999", then select "SOCKS v5". It's easy.
+
 
+
[[Image:Firefox_socks_settings.png]]
+
 
+
This tool can also help in switching the proxy settings on and off:
+
[http://addons.mozilla.org/en-US/firefox/addon/125 SwitchProxy Tool]
+
 
+
== Remote Server Security Enhancement with SSH Keys ==
+
 
+
You can make port forwarding even more secure by limiting what a privileged account can do. When you add a key to authorized_key you may pass parameters to fine tune the connection. This can be used to restrict what the client is allowed to do. On the remote server, add the following to ~username/.ssh/authorized_keys:
+
 
+
<pre>
+
from="192.168.1.69",command="/bin/false",no-pty,no-X11-forwarding,no-agent-forwarding,no-port-forwarding,permitopen="localhost:143"
+
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA8XIr8LEXdvc4VZEvNenWkJrerTzNhqTT7QvCD+Y2EjCUPQwfBcSnvhY3oasNigNonghQFqm7/HqWBLpcN+4mqDUrXrEdj6HQmHvCV6WozNUVb5jjiyQ/JF4hqcQd6oelCkVw8wD32I2jlYqydpqOGY4xqakWDAfm3SOx5il3Kl49mKCg5B3GQPexhTujaTT3y/Q1eeT3zGpHE9Mp7k20X8rMxSjp5ncLAmdf42fRh05HY5f1GrupQIEdi0/TDcPNWL1ml89zttrDOLgDnwny7P0x2jmcX41cSxL/8svER7BAk2sroyQe6L21pJ7o2MYz1IwnsQgji/GjJoaA7hTNCQ== username@client.example.com
+
</pre>
+
 
+
* from="192.168.1.69": accept connection only from the given IP address
+
* command="/bin/false": forces this command to be run no matter what is passed via ssh from the client
+
* no-pty: never allocate a PTY for interactivity
+
* no-X11-forwarding: No X11
+
* no-agent-forwarding: we don't want or need ssh-agent
+
* no-port-forwarding: prevent ssh -R ...
+
* permitopen="localhost:143": allow only localhost connections to port 143 for `ssh -L` requests
+
 
+
== reverse port forwarding ==
+
Sometimes I need to make an internal LAN machine expose a service to the outside WAN.
+
For example, I have a database server that will only accept connections from a
+
specific development box. That dev box is inside the firewall. I want to connect to
+
the database from outside the firewall.
+
<pre>ssh -t -L 5432:localhost:1999 my_name@firewall.example.com ssh -t db_server ssh -t -R 1999:127.0.0.1:5432 my_name@firewall
+
</pre>
+
 
+
 
+
== SSH for Windows ==
+
[http://www.chiark.greenend.org.uk/~sgtatham/putty/ Putty] is the best free SSH client for Windows. You can also use [http://www.cygwin.com Cygwin], but the ANSI terminal emulation isn't as good unless you start the X11 server and run xterm.
+
 
+
== MindTerm SSH client Java Applet ==
+
MindTerm_2.1 (non-commercial). This was the last free version of MindTerm.
+
 
+
    [http://www.noah.org/engineering/mindterm/mindterm.jar mindterm.jar]
+
 
+
Put this applet on a web page and point the <applet> "archive" attribute to the URL of the JAR file:
+
<small><pre>
+
<applet archive="mindterm.jar" code="com.mindbright.application.MindTerm.class" width="580" height="400">
+
    <param name="te" value="xterm-color"> <!-- "vt102" -->
+
    <param name="fs" value="18">
+
    <param name="gm" value="80x32+0+0">
+
    <param name="port" value="22">
+
    <param name="cipher" value="blowfish"> <!-- "des" -->
+
    <param name="usrname" value="">
+
    <param name="sepframe" value="false">
+
    <param name="quiet" value="false">
+
    <param name="cmdsh" value="false">
+
    <param name="verbose" value="true">
+
    <pa ram name="autoprops" value="none">
+
    <param name="idhost" value="false">
+
    <param name="alive" value="10">
+
    <param name="appletbg" value="white">
+
</applet>
+
</pre></small>
+
 
+
<include iframe src="http://www.noah.org/engineering/mindterm/mindterm_iframe.html" width="630" height="460px" />
+

Latest revision as of 00:14, 22 October 2008

Subcategories

This category has only the following subcategory.

S

Pages in category "SSH"

The following 7 pages are in this category, out of 7 total.