Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have a process that is using a working secured port using this scp command like so:

/usr/bin/scp -P 1234 -i /path/key_rsa /home/path/filename.txt user@remotehost:/tmp

I'm working on a schell script, that will use ssh, but not sure how to use that same port of 1234.

I tried /usr/bin/ssh -D 1234 remotehost '. ~/my_profile; mkdir /test' and its asking for the user pw. I know the keys are already established since the scp works fine for that user.

What am I doing wrong? Thanks.

share|improve this question
up vote 7 down vote accepted

You want to use the -p option; -D is for dynamic port forwarding, that is to say creating port forwardings on an existing connection.

share|improve this answer
thanks! – jdamae Mar 5 '11 at 1:04

Your Answer


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.