0

I am trying to do SSH where target server is accessible through jump server only.

 +-------+       +----------+      +--------------+
 | Laptop| <---> | Jumphost | <--> | TargetServer |
 +-------+       +----------+      +--------------+

To access the server, I have to use my private key.

I recently shifted to MAC from Windows machine. In windows I was using WINSCP tool and through tunnel option in WINSCP and Allowing agent forwarding I was able to access the target servers.

Target server setting: enter image description here

Tunnel setting: enter image description here

Authentication/Agent forwarding setting enter image description here

I have placed same private key in both the settings.

Now I am looking for direct SSH command (to execute on MAC) so that I can access servers.

I have tried the following command

ssh -i privatekey.pem -Ao ProxyCommand="ssh -i privatekey.pem user@jumpserver" user@targethostname

but getting an error:

-bash: line 1: $'SSH-2.0-OpenSSH_7.6\r': command not found

1
  • You probably have some alias defined, that expands some of your constants to something you don't want. What is output of alias? Write set -x, press enter and write your command again. What is the output?
    – Jakuje
    Commented Jul 30, 2018 at 22:24

1 Answer 1

2

Following command worked for me

ssh -i privatekey.pem -o "ProxyCommand ssh -W %h:%p -i privatekey.pem user@jumpserverhost" user@targetserver
1
  • Welcome to superuser: While this may or may not answer the question, it would be a better answer if you could provide some more explanation why your solution works with detail and easy to follow instructions so that the readers who do not understand code as well as others can use the answer as well. If you feel your answer is correct and fix's the problem then re-edit it. Please take a couple of minutes and read:- .Answering: help center, How to Answer, again welcome to superuser and keep answering. Thankyou
    – mic84
    Commented Jul 31, 2018 at 3:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .