1

Let's say I have two machines: A and B.

  1. A has installed SSH server and client
  2. B has installed only SSH client
  3. Connection between both machines is working

I know that I can issue following command from machine B:

ssh A

and It will give me the console of machine A.

Is possible to somehow achieve similar but opposite way, get the B console from A?

Wakan Tanka
  • 749
  • 2
  • 13
  • 31

2 Answers2

2

No you can't do that. There should be something running on B that serves the clients.

If the issue is only allowing connection after an initial SSH connection, you can set up a reverse SSH tunnel over the first SSH connection and open new SSH connection over the tunnel. But you still need to run SSH server on B.

  • What about some reverse shells etc.? – Wakan Tanka Feb 27 '15 at 22:00
  • "Reverse shell" is a term used in security context, which denotes that a server might access a client machine by using an exploit, without the client's consent. Establishing a connection this way might be possible by installing an exploited ssh client, however this is not a proper way.

    If you insist of achieving this, you should look at custom protocols or applications. For example you can run team viewer over an ssh tunnel you created. But whatever you do, you need to run some server on client machine,there is no other way. Ssh itself does not support this kind of reverse connections.

    – infiniteRefactor Feb 28 '15 at 12:59
1

If machine B has a telnet server running, you can use the ssh connection from B to A to forward the telnet port so that machine A can connect to it even if direct access to the port is blocked by a firewall (as it should be). Assuming telnet is listening on the default port (23) on machine B, you'd do something like ssh -R 23:localhost:2023 A. A user on A could then use telnet localhost 2023 to connect to a shell on B. (We're using port 2023 instead of 23 at the far end because you need to be root to listen on a port number below 1024.)

I don't know of any way to do it without some kind of login server running locally on machine B.

Mike Scott
  • 4,443
  • Don't you know of some minimal login server? I think it only purpose should be somehow to redirect traffic to bash which will handle all stuff. – Wakan Tanka Feb 27 '15 at 22:03
  • 1
    @WakanTanka Yes, I do know of such a server. It's called telnetd. That's what telnet is -- it's a server that just receives incoming connections and executes a shell to handle them. – Mike Scott Feb 28 '15 at 06:18