
要塞ホストがあります。ユーザー名/パスワードを使用して要塞ホストに接続します。また、宛先サーバーの秘密鍵を持っています。フロー:
Local Machine -> Bastion -> Destination
使用するのは危険だとわかっていますエージェント転送誰かが私のソケットファイル(彼らが要塞ホストへのルートアクセス権を持っている場合)セッションは開いています宛先サーバーにアクセスするには、プロキシコマンド!
今私はただテスト 宛先サーバーにアクセスする方法秘密鍵なしもし私が要塞サーバーへのアクセス- エージェント転送はどれほど危険か。
Host bast
Hostname X.X.X.X
ForwardAgent yes
User bastion
質問:
アクティブ エージェントに関する情報が、要塞サーバーの次の場所にあることがわかりました。例: /tmp/ssh-{名前}/agent.[PID]ルート権限を持っていますが、このファイルを読むことができません。プロセスIDだけで十分ですこのファイルの場合、そうではありませんか?
エージェント転送が有効になっている場合、ソケットファイルはどこにありますか?/proc/pid/fd/いくつかのソケット ファイルを確認した場所。
ソケット ファイルを使用して宛先サーバーにアクセスするにはどうすればよいですか? (ソケット ファイルを使用して SSH 経由で宛先サーバーにアクセスする方法)
ここでソケット ファイルを検索しようとしました:
/proc/PID/fd/
次に、各ソケット 3、4、5、9、11 に対して次のコマンドを試してください。
ssh -p 2072 -o "ProxyCommand socat - UNIX-CLIENT:/proc/PID/fd/11" app@[DESTINATION_HOST_URL]
結果:
2018/08/26 01:53:31 socat[13552] E connect(5, AF=1 "/proc/13510/fd/11", 19): Connection refused
ssh_exchange_identification: Connection closed by remote host
ログ:
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Executing proxy command: exec socat - UNIX-CLIENT:/proc/14003/fd/11
debug1: permanently_set_uid: 0/0
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: permanently_drop_suid: 0
2018/08/26 03:10:17 socat[14073] E connect(5, AF=1 "/proc/14003/fd/11", 19): Connection refused
ssh_exchange_identification: Connection closed by remote host
答え1
キーがロードされたSSH_AUTH_SOCK
ので、値を変更しました。ssh-add -l
まとめると、エージェント転送を使用するのは危険です。要塞ホストへのルートアクセス権を持っている場合、セッション全体が開いているときにキーを盗むことができるからです。変更するだけで済みますSSH_AUTH_SOCK
。