1

I have a server which I access over ssh with pubkey-authentication like so:

ssh "Host" -l "my identity" 

This works very well. However, I cant do port redirection and identification with my private key in one command (this is what I tried):

ssh "Host" -L 127.0.0.1:19000:"Host":445 -l "my identity" 

ssh then asks for the password for the user "my Identity"@"Host", which of course I don't have, because I want to connect with my private key (I tried the password which the private key is encrypted with - it didn't work).

It however works when I first create a normal ssh tunnel and then a second one with the port redirection.

So my question in short: How can i authenticate with my private key AND do a port redirection in one command?

1 Answer 1

1

You should specify the options in front of the hostname, as the manual page for ssh(1) hints:

 ssh [...] [-L [bind_address:]port:host:hostport] [-l login_name] [...] [user@]hostname [command] 

The parsing of arguments after the hostname can be suppressed or omitted since it is not according to specification.

You should rather use:

ssh -L 127.0.0.1:19000:"Host":445 -l "my identity" "Host" 

Which should work just fine as your previous command.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your answer, this worked like a charm! =)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.