Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

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).

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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