ssh -D doesn't establish tunnel, it just connect as interactive session. Why?

2

I am trying to create a SOCKS5 tunnel, but for some reason using -D does not work. Here is an excerpt:

laptop:~ localuser$ ssh -D 8080 -p 2222 remoteuser@remotehost.com
remoteuser@remotehost.com's password: 
Last login: Mon Apr 22 08:49:37 2013 from 207.167.42.77
remoteuser@remotehost.com [~]# 

It creates an interactive session rather than opening a port. Why?

ToddB

Posted 2013-04-22T15:30:01.173

Reputation: 123

Answers

4

This is the correct behavior. SSH establishes a tunnel and opens an interactive session. If you want the tunnel only, use the -N option of ssh; you might also be interested in combining that with -f:

ssh -Nf -D 8080 -p 2222 remoteuser@remotehost.com

From man ssh

-f Requests ssh to go to background just before command execution. This is useful if ssh is going to ask for passwords or passphrases, but the user wants it in the background. (...)

-N Do not execute a remote command. This is useful for just forwarding ports (protocol version 2 only).

mpy

Posted 2013-04-22T15:30:01.173

Reputation: 20 866

1

You are missing -N

And if you don't want a running session and just the tunnel use -f

ssh -f -D 8080 -p 2222 remoteuser@remotehost.com -N

DaveDeveloper

Posted 2013-04-22T15:30:01.173

Reputation: 62