マルチホップSSH構成と「sudo su」

マルチホップSSH構成と「sudo su」

次の一連の手順が必要な特定の設定があります。

ssh me@host1
ssh me@host2
sudo su otheruser

私は持っています:

  • 私のラップトップには、次のことを許可するSSHキーがあります。ssh me@host1
  • Host1のSSHキーを使用するとssh me@host2

はいいいえ権利がありますssh otheruser@host2

私の目標は:これを自動化できますか?私のラップトップの〜/ .ssh / configファイルにあることが望ましいので、単に次のことができます。

ssh otheruser

...設定でパスワードを含む詳細を処理しますか?

次のSSH構成では、すでに2/3パスを取得できます。

Host host1
HostName host1.example.com

Host host2
HostName host2.example.com

Host mostly_there
HostName host2.example.com
ProxyJump host1 host2

上記を使用してこれを行うことはできますが、ssh mostly_thereまだ実行する必要がありますsudo su otheruser

ベストアンサー1

.ssh/configでこれを使用できます。

HOST host1
  user me

HOST host2
    USER me
    ProxyCommand ssh host1 -W %h:%p

HOST otheruser
    USER me
    ProxyCommand ssh host1 -W %h:%p
    RemoteCommand sudo su -c '/bin/bash -i' otheruser

otheruserユーザーを使用してホスト2に接続するには、次のようにします。

ssh otheruser

現在、完全な対話型シェルではありませんが、次の方法でアクセスできるという欠点があります。/bin/bash -i

おすすめ記事