简体   繁体   中英

Nested ssh tunnel command from within ssh not working

Assume machine A has an ssh tunnel to machine C via B , eg

ssh -N -L 12345:C:22 userB@B

which means that we are able to execute the ls command from A on C as follows:

ssh -p 12345 userC@localhost 'ls'

Up to now all this works and has been tested.

The problem is if there is another machine Z which has access to A , eg from Z we can run:

ssh userA@A 'ls'

and it works. But this does not work:

ssh userA@A "ssh -p 12345 userC@localhost 'ls'"

The error message is Permission denied (publickey,password)

Any ideas? I do not use passwords but private/public keys for authentication. The mystery is that if I do not nest the commands all works, ie I can executed a command on A from Z , I can execute a command on C from A , but I cannot execute the same command on C from Z . Any help is appreciated.

嵌套的隧道不是很漂亮。...考虑一个运行ssh的加固堡垒主机...连接到该主机,启用tmux和ssh到远程内部主机。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM