То, что вы делаете, не открывает второе соединение из вашего экземпляра AWS. Он открывает соединение из того места, где запускается скрипт.
Вам следует искать опцию ProxyJump
. Это позволит вам связать несколько SSH-соединений.
Вот выдержка со страницы man
:
ProxyJump
Specifies one or more jump proxies as either [user@]host[:port] or an ssh URI. Multiple proxies may be separated by comma characters and will be visited sequentially. Setting this option will cause ssh(1) to connect
to the target host by first making a ssh(1) connection to the specified ProxyJump host and then establishing a TCP forwarding to the ultimate target from there.
Note that this option will compete with the ProxyCommand option - whichever is specified first will prevent later instances of the other from taking effect.
Note also that the configuration for the destination host (either supplied via the command-line or the configuration file) is not generally applied to jump hosts. ~/.ssh/config should be used if specific configuration
is required for jump hosts.
при подключении к Pi по SSH обязательно настройте XForwarding:
ssh -X foo@pi
Затем вызовите любую клиентскую команду x, которая вам нравится; это традиция проверять с помощьюxeyes
Если это работает так, как ожидалось, вам может даже не понадобиться NoMachine, хотя я думаю, что он должен работать быстрее.