
我們在工作中使用VPC 中的Bastion 連接到多個私人伺服器,我設定了別名(ssh 主機別名)來加快彈回到下一個伺服器的過程,但這是一個緩慢的過程,許多用戶最終會發現我們的配置找到合適的別名。我想找出一種方法讓我們的用戶能夠透過 Bastion 進行 ssh / sftp ?有誰知道可接受的方法?我簡要地研究了 mosh-server 但不確定這是否是正確的方法。
答案1
假設 Linux/MacOS 上使用 OpenSSH。 Putty 可能提供類似的功能。
ProxyCommand
告訴您的使用者在他們的 ~/.ssh/config 檔案中使用:
cat ~/.ssh/config
Host !bastion.example.com *.example.com
ProxyCommand ssh -q -a [email protected] nc %h %p
IdentityFile ~/.ssh/id_rsa
如果您隨後嘗試連線到test.example.com
,ssh 將自動透過隧道連接此連線bastion.example.com
。
如果您願意,您可以為此添加無限的靈活性。