# How to bypass lost access to ssh?



## Mad_Dud (Nov 13, 2010)

Hi,

Something happened and I can't log in via ssh anymore:


```
$ ssh -vvv hostname
OpenSSH_5.3p1 Debian-3ubuntu4, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to hostname [x.x.x.x] port 22.
debug1: Connection established.
debug1: identity file /home/mduda/.ssh/identity type -1
debug1: identity file /home/mduda/.ssh/id_rsa type -1
debug3: Not a RSA1 key file /home/mduda/.ssh/id_dsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /home/mduda/.ssh/id_dsa type 2
debug1: Checking blacklist file /usr/share/ssh/blacklist.DSA-1024
debug1: Checking blacklist file /etc/ssh/blacklist.DSA-1024
ssh_exchange_identification: Connection closed by remote host
```

I haven't done any changes to ssh config recently, I used to log in using pub_key auth method everyday. I don't have physical access to machine and I have root password.

I believe that I can manage to reestablish connection using currently existing ssh socks tunnel:

```
ssh -qTfnN -D 7070 -C login@hostname
```
This tunnel has been opened couple of hours ago hour later I couldn't connect via ssh anymore.

Things I've already tried:

logging in using password method
logging in from different hosts
logging in from different ips

I really believe that I can do something with this ssh socks connection (which is still alive). Do you, guys, have any idea how to inject commands to be executed on this remote host via ssh socket?
I was thinking about netcat and -e flag, but it seems that BSD version of netcat does not work as i expected.

Regards
Dud


----------



## gordon@ (Nov 14, 2010)

Been thinking about it, I can't think of anything off the top of my head with the SSH session you have setup. With no ability to feed a stdin to the existing ssh session, I don't think there is much you can do.


----------



## Mad_Dud (Nov 14, 2010)

Thank you for your time. I ended up hard restarting the box and now everything works fine.
Can you suggest any methods, which can help in this situations? Can I prepare myself for something like this?
Currently i left session with open ssh connection to this unfortunate server on yet another box.


----------

