Linux – Hijacking a SSH connection from the server to control the client

linuxssh

Awkward problem: for some reason, I can't reach our Linux server by SSH. Everything else works. Since it doesn't have a graphics card (I had to remove it to make room for another NIC) I can only control it "blindly" by typing on the keyboard.

By typing blindly I managed to eliminate the firewall as an issue by deactivating it. I rebooted the server but SSH doesn't seem to come up at all.

Now I managed to initiate a SSH connection from the server to my workstation. Is there any way I can hijack that connection to get a terminal on the server that I can control from my workstation? Using a tunnel doesn't work since the SSH daemon doesn't start at all.

The server is an Ubuntu 8.04 LTS box, my workstation is Ubuntu 11.04. On the server, the following software is running:

  • Apache with mod_php
  • BIND
  • FTP
  • CUPS
  • Postgres
  • MySQL
  • SANE

Best Answer

You can setup a reverse proxy SSH tunnel like so:

(blindly) from the server, you need to SSH out to another box running an ssh daemon (like Linux, Mac, or WinSSHD):

ssh -R 9999:localhost:22 otherboxuser@other.box.IP.address

port 9999 is just an arbitrary/unused port.

Now you can SSH from your other box to the blind server by tunneling through the connection you're already established:

ssh localhost -p 9999

Get yourself a USB video card dongle or find a video card that'll fit in whatever slot you have remaining.