1

So, I have configured my linux ubuntu 14.04 box for ssh on port 22 with root login via private / public key, no password login.

I have iptables setup to block all incoming connections except for port 22, and the loop back interface. I inadvertently changed the SSH port to a new port (not 22).

I don't have physical access to the box. Is my only choice just to re-image the box?

2

If your iptables rule was temporary, you could try a reboot. Else, you would need console access to the machine, in which you could boot into single user mode and change it back. Otherwise, you have effectively firewalled yourself out and would need to re-image if you can't get a console.

6
  • I have a console, just not a privileged console
    – Ryan
    Jul 12 '14 at 2:32
  • @true If you're still logged into the machine, then just sudo and fix it. Jul 12 '14 at 2:33
  • I'm not part of the sudoers file. Think I'm out of options?
    – Ryan
    Jul 12 '14 at 2:34
  • If you don't have permissions to manipulate the ssh service or iptables, then you are probably out of options.
    – Peter
    Jul 12 '14 at 3:08
  • 3
    If you have access to the machine as a non root user you should be able to ssh to localhost from that window and log in (as localhost is not firewalled). You will need to pull your private key onto the box somehow though - maybe copy and paste it ?
    – davidgo
    Jul 12 '14 at 3:36
2

If you have a remote console and can remotely re-image the box, you should be able to remotely boot a rescue image as well. If that is not possible for some reason (lack of admin access to tftp/dhcp/pxe servers, no remote power control, etc.), maybe you could use a local exploit of some sort, eg (since I don't know the exact kernel version) http://www.ubuntu.com/usn/usn-2274-1/.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.