<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  
  
  <channel>
    <title>chrisjrob: ssh</title>
    <link>https://chrisjrob.com</link>
    <atom:link href="https://chrisjrob.com/tag/ssh/feed/index.xml" rel="self" type="application/rss+xml" />
    <description>GNU Linux, Perl and FLOSS</description>
    <language>en-gb</language>
    <pubDate>Fri, 13 Feb 2026 17:22:31 +0000</pubDate>
    <lastBuildDate>Fri, 13 Feb 2026 17:22:31 +0000</lastBuildDate>
    
    <item>
      <title>Dynamic Dns and Remote ssh and VNC</title>
      <link>https://chrisjrob.com/2011/04/05/dynamic-dns-and-remote-ssh-and-vnc/</link>
      <pubDate>Tue, 05 Apr 2011 00:00:00 +0000</pubDate>
      <author>chrisjrob@gmail.com (Chris Roberts)</author>
      <guid>https://chrisjrob.com/2011/04/05/dynamic-dns-and-remote-ssh-and-vnc</guid>
      <description>
       <![CDATA[
         
         <p>I want to be able to support my father’s PC remotely via SSH and VNC.
Some people recommend teamviewer, but I prefer the flexibility and
security of ssh, and the fact that this approach is fully open source.</p>

<h2 id="step-1-sign-up-for-dynamic-dns">Step 1: Sign up for Dynamic DNS</h2>

<!--more-->

<p>The first problem is that most people’s Internet service do not have a
static IP address. In practice it is fairly static on modern broadband
services, but, if you do not want to be fiddling about trying to find
out what the current IP address is, then you need a dynamic DNS
service.</p>

<p>Dynamic DNS gives you an unchanging address which is automatically
mapped to the current IP address, whatever that might be. So for example
you might have <code class="language-plaintext highlighter-rouge">daddy.dyndns.xyz</code> as your address. To make this work,
you need to have a client machine on the network, that will keep
updating daddy.dyndns.xyz with the latest IP address. Some home routers
have this functionality built in.</p>

<p>I did some research and determined that the very popular
<a href="http://dyndns.com">http://dyndns.com</a> service is reliable, and so I went ahead and signed
up a new account for my father, and set-up a hostname for his router’s
WAN address.</p>

<h2 id="step-2-configure-client">Step 2: Configure Client</h2>

<p>If you’re lucky your router will support dynamic DNS. My father’s did,
so I just logged onto the router and entered the dyndns account
information, and it just worked perfectly.</p>

<p>If your router does not support dynamic DNS, all is not lost, simply
install ddclient on a computer on the network (presumably, but not
necessarily, the one that you want to be supporting):</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ sudo apt-get install ddclient`
</code></pre></div></div>

<p>Configuration of ddclient is simple, the ncurses configuration process
takes you step-by-step through the necessary steps.</p>

<h2 id="step-3-configure-port-forwarding">Step 3: Configure port forwarding</h2>

<p>The next problem is that your router has a firewall that is designed
explicitly to stop people getting into your network. We need to punch a
small hole in that firewall. Needless to say this does have security
implications, so we need to be careful.</p>

<p>So we need to open a port on the router and forward it to the machine
that we wish to support. This machine does need to have a static IP
address.</p>

<p>Log onto your router via its web management page. The main difficulty
here is in finding the port forwarding option, when it is probably
called something user friendly like Game Sharing or some other
perversely unhelpful name. If you can’t find it, then you’re best of
Googling for “port forwarding routername” where routername is the make
and model of your router. Or just read the manual, if by some miracle
you have one to hand.</p>

<p>But which port to forward? Your router will probably make it easy to
forward the standard ssh port - port 22 - the problem is that everyone
knows that is the ssh port and you may experience a high number of
attacks on that port. In theory you should be safe enough with secure
passwords, but personally I would not choose to forward the standard ssh
port, but would instead add a custom service “ssh_obscure” on a
different TCP port number and forward that to port 22 on PC that you
wish to support:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Name: ssh_obscure
Protocol: TCP
Source port: 2121 (or whatever you choose)
Destination IP: (enter the client PC's IP)
Destination Port: 22
</code></pre></div></div>

<p>If it won’t let you specify a Destination Port, then it will forward to
the same custom port on the PC. This will then require a change in the
configuration of sshd on the PC, which I will explain in the next step.</p>

<h2 id="step-4-install-openssh-server">Step 4: Install openssh-server</h2>

<p>On the client PC, i.e. the PC you will be supporting, install
openssh-server and its dependencies:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ sudo apt-get install openssh-server
</code></pre></div></div>

<p>If you didn’t bother with the ssh_obscure suggestion above, then you
are simply forwarding from port 22 on the router to port 22 on the
client and no further configuration of openssh is required.</p>

<p>If you did set-up the ssh_obscure, but forwarding to port 22 on the
client, then again no further configuration is required.</p>

<p>If you set up ssh_obscure, but were unable to set a Destination Port,
then you are forwarding the same port to the client, so you will need to
change the relevant setting in <code class="language-plaintext highlighter-rouge">/etc/ssh/sshd_config</code>. E.g. <code class="language-plaintext highlighter-rouge">Port 2121</code>.
Then reload the ssh configuration with:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ sudo /etc/init.d/ssh force-reload
</code></pre></div></div>

<h2 id="step-5-install-fail2ban">Step 5: Install Fail2ban</h2>

<p>As stated above, we have reduced the security of your network by taking
these steps and we are now going to attempt to rectify this somewhat by
installing fail2ban.</p>

<p>Some argue that this is unnecessary, if you have set a custom port for
ssh and maintain secure passwords, but I see no reason for relying on
security by obscurity. The main benefit of using a custom ssh port is to
prevent the attempts in the first place, but <strong>hiding your front door is
no substitute for locking it</strong>.</p>

<p>Fail2ban will monitor your <code class="language-plaintext highlighter-rouge">/var/log/auth.log</code> and block any hosts that
have repeatedly failed to login correctly, by blocking them in iptables
(the standard Linux firewall).</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ sudo apt-get install fail2ban
</code></pre></div></div>

<p>Next you should create a new file <code class="language-plaintext highlighter-rouge">/etc/fail2ban/jail.local</code>, with the
following contents:\</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[ssh]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
maxretry = 3
bantime = 600
</code></pre></div></div>

<p>Strictly speaking the above is already configured in
<code class="language-plaintext highlighter-rouge">/etc/fail2ban/jail.conf</code>, but I think it makes sense to take ownership
of those settings by redefining them in jail.local. If you have set a
custom ssh port, then set it in jail.local as above, replacing 
<code class="language-plaintext highlighter-rouge">port = ssh</code> with <code class="language-plaintext highlighter-rouge">port = 2121</code> or whatever. I have reduced maxretry to 3 from
the default of 6, as I found it was giving nearer to 18 attempts, thanks
to the peculiarities of the auth.log file.</p>

<p>Finally reload these new settings in fail2ban:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ sudo /etc/init.d/fail2ban force-reload
</code></pre></div></div>

<p>In order to test fail2ban, try and log into the client from another
machine on the same network. You will need attempt to log in with the
wrong password a number of times. This may not be exactly 3 times, but
if you get to 9 attempts and it still has not blocked you, then there is
problem.</p>

<p>fail2ban will only block you for 10 minutes, after 3 failed login
attempts (you can change these settings as above).</p>

<h2 id="step-6-testing-ssh">Step 6: Testing SSH</h2>

<p>At this stage you should be able to log in remotely to your client PC.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ ssh -p 2121 username@daddy.dyndns.xyz
</code></pre></div></div>

<p>Obviously change 2121 for your custom port, or leave out <code class="language-plaintext highlighter-rouge">-p 2121</code> if
you are using the standard ssh port 22.</p>

<h2 id="step-7-installing-vnc">Step 7: Installing VNC</h2>

<p>Having ssh access is wonderful, but not much help when your Dad asks you
where his OpenOffice toolbar has gone; so we need to add VNC on the PC
you wish to support:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ sudo apt-get install x11vnc
</code></pre></div></div>

<p>And on the PC from which you will be providing support you need to
install vnc-viewer, or use your preferred vncviewer:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ sudo apt-get install xvnc4viewer
</code></pre></div></div>

<h2 id="step-8-testing-vnc">Step 8: Testing VNC</h2>

<p>Now, you <em>could</em> have set up x11vnc to be running permanently with a
password, and then you could set your router to port forward a custom
VNC port to the client PC. This approach does significantly degrade your
security and is in any case unnecessary. Instead we can just run it when
we need it by using ssh, by typing this command <strong>from the PC from which
you will be providing support</strong> and changing as appropriate:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ ssh -p 2121 -t -L 5900:localhost:5900 username@daddy.dyndns.xyz 'x11vnc -noxdamage -localhost -display :0'
</code></pre></div></div>

<p>This will connect by ssh to the client machine, run x11vnc bound only to
localhost (so no-one else can connect to it) and build a tunnel between
the remote VNC port to your local VNC port.</p>

<p>One caveat is that the username needs to be the currently logged in
user, otherwise x11vnc will refuse to start.</p>

<p>And finally on the PC from which you are providing support we just run:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>vncviewer localhost:0
</code></pre></div></div>

<p>And you should now be looking at your father’s (or whoever’s) PC.</p>

<p>Whilst this does all sound pretty involved, all but this final step is
only required once, then a quick ssh command and vncviewer and you are
connected.</p>


       ]]>
      </description>
    </item>
    
    <item>
      <title>LTSP | LTSP Update SSH Keys</title>
      <link>https://chrisjrob.com/2010/03/30/ltsp-update-ssh-keys/</link>
      <pubDate>Tue, 30 Mar 2010 09:20:24 +0000</pubDate>
      <author>chrisjrob@gmail.com (Chris Roberts)</author>
      <guid>https://chrisjrob.com/2010/03/30/ltsp-update-ssh-keys</guid>
      <description>
       <![CDATA[
         
           <img src="https://chrisjrob.com/assets/ltsp_logo.png" align="right" alt="Featured Image">
         
         <h2 id="command">Command</h2>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ltsp-update-sshkeys
</code></pre></div></div>

<h2 id="introduction">Introduction</h2>

<p>Secure Shell Handler or SSH is a network protocol that allows data to be exchanged using a secure channel between two computers.  LTSP uses it to enable secure communication between clients and the Server.  SSH uses public-key cryptography to authenticate the client, this command rebuilds the keys.</p>

<!--more-->

<p>You would run this command only at first install, or upon subsequent change of server IP addressing or DHCP or possibly hosts.  Basically if you get the “workstation not authorised” message, then you should run this command.</p>


       ]]>
      </description>
    </item>
    
    <item>
      <title>Howto | DD over SSH</title>
      <link>https://chrisjrob.com/2009/10/09/dd-over-ssh/</link>
      <pubDate>Fri, 09 Oct 2009 00:00:00 +0000</pubDate>
      <author>chrisjrob@gmail.com (Chris Roberts)</author>
      <guid>https://chrisjrob.com/2009/10/09/dd-over-ssh</guid>
      <description>
       <![CDATA[
         
         <p>Wow, can’t believe my last post was 4 months ago, well a quick tip to get me back into the blogging frame of mind.  If you wish to take a drive image copy over the network, then apparently you do not have to have an nfs share available.  Instead you can use ssh as follows:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ dd if=/dev/sda bs=1M | ssh root@blah "cat &gt; /root/disk.img"
</code></pre></div></div>

<!--more-->

<p>Haven’t tried it yet, but it sounds incredible.  The <code class="language-plaintext highlighter-rouge">bs=1M</code> is essential or the copy will take forever.</p>

       ]]>
      </description>
    </item>
    
  </channel> 
</rss>
