“vagrant ssh” コマンドのログを取る方法

投稿者: | ↻ : 2019年1月28日

Vagrantで構築した仮想マシンへvagrant sshコマンドで接続する際に、内部で使用しているsshコマンドのログを取得するには次のようにします。


$ vagrant ssh -- -v -E sample.log

詳細は続きへ…

検証環境

macOS

macOS Sierra 10.12.6
Vagrant 2.0.0

Windows

Microsoft Windows 10.0.14393
Git 2.14.2 (Git Bash利用)
Vagrant 1.9.8
(2.0.0にはrsyncの実行にバグがある、修正のプルリクが取り込まれているので次のリリースに期待)

コマンド

公式サイトCommands(CLI) – sshに詳しい説明があります。

書式

vagrant ssh [name|id] [– extra_ssh_args]

説明

— (ハイフン2つ)以降は、sshコマンドへの引数として扱われます。
ハイフン2つをオプションに付けるのではなく、区切りとして使用します。

実行例

macOS


$ vagrant ssh -- -v -E sample.log

Last login: Sat Oct  7 10:58:52 2017 from 10.0.2.2
[vagrant@localhost ~]$ exit
logout
Connection to 127.0.0.1 closed.

ringo@stupiddog  ~/vm/centos $ head -n 4 sample.log 
OpenSSH_7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 2222.
debug1: Connection established.

Windows 10 (Git Bash)


stupiddog@DESKTOP-I5SF6NO MINGW64 /c/vm/php
$ vagrant ssh -- -v -E sample.log
Last login: Sat Oct  7 11:30:51 2017 from 10.0.2.2
[vagrant@localhost ~]$ exit
logout
Connection to 127.0.0.1 closed.

stupiddog@DESKTOP-I5SF6NO MINGW64 /c/vm/php
$ head -n 4 sample.log
OpenSSH_7.5p1, OpenSSL 1.0.2k  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 2222.
debug1: Connection established.