質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Vagrant

Vagrantは、VirtualBox上の仮想マシンを コマンドラインから作成してくれるソフトウェアです。 ビルド環境など容易に構築が可能です。

Q&A

解決済

3回答

771閲覧

vagrantへputtyから接続できない(タイムアウト)

Yasu0421

総合スコア37

Vagrant

Vagrantは、VirtualBox上の仮想マシンを コマンドラインから作成してくれるソフトウェアです。 ビルド環境など容易に構築が可能です。

0グッド

0クリップ

投稿2018/11/12 00:05

vagrant+virtualboxの仮想環境へputtyから接続すると、タイムアウトが発生し、接続できない
状況です。ご回答いただけると幸いです。

vagrantfile内容は以下の通りです。

vagrantfiel

1# -*- mode: ruby -*- 2# vi: set ft=ruby : 3 4# All Vagrant configuration is done below. The "2" in Vagrant.configure 5# configures the configuration version (we support older styles for 6# backwards compatibility). Please don't change it unless you know what 7# you're doing. 8Vagrant.configure("2") do |config| 9 # The most common configuration options are documented and commented below. 10 # For a complete reference, please see the online documentation at 11 # https://docs.vagrantup.com. 12 13 # Every Vagrant development environment requires a box. You can search for 14 # boxes at https://vagrantcloud.com/search. 15 config.vm.box = "bento/centos-6.8" 16 17 # Disable automatic box update checking. If you disable this, then 18 # boxes will only be checked for updates when the user runs 19 # `vagrant box outdated`. This is not recommended. 20 # config.vm.box_check_update = false 21 22 # Create a forwarded port mapping which allows access to a specific port 23 # within the machine from a port on the host machine. In the example below, 24 # accessing "localhost:8080" will access port 80 on the guest machine. 25 # NOTE: This will enable public access to the opened port 26 # config.vm.network "forwarded_port", guest: 80, host: 8080 27 28 # Create a forwarded port mapping which allows access to a specific port 29 # within the machine from a port on the host machine and only allow access 30 # via 127.0.0.1 to disable public access 31 # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" 32 33 # Create a private network, which allows host-only access to the machine 34 # using a specific IP. 35 config.vm.network "private_network", ip: "192.168.33.10" 36 # config.vm.network "private_network", ip: "127.0.0.1" 37 38 # Create a public network, which generally matched to bridged network. 39 # Bridged networks make the machine appear as another physical device on 40 # your network. 41 # config.vm.network "public_network" 42 43 # Share an additional folder to the guest VM. The first argument is 44 # the path on the host to the actual folder. The second argument is 45 # the path on the guest to mount the folder. And the optional third 46 # argument is a set of non-required options. 47 # config.vm.synced_folder "../data", "/vagrant_data" 48 49 # Provider-specific configuration so you can fine-tune various 50 # backing providers for Vagrant. These expose provider-specific options. 51 # Example for VirtualBox: 52 # 53 # config.vm.provider "virtualbox" do |vb| 54 # # Display the VirtualBox GUI when booting the machine 55 # vb.gui = true 56 # 57 # # Customize the amount of memory on the VM: 58 # vb.memory = "1024" 59 # end 60 # 61 # View the documentation for the provider you are using for more 62 # information on available options. 63 64 # Enable provisioning with a shell script. Additional provisioners such as 65 # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the 66 # documentation for more information about their specific syntax and use. 67 # config.vm.provision "shell", inline: <<-SHELL 68 # apt-get update 69 # apt-get install -y apache2 70 # SHELL 71end

1.Vagrantの状況

1-1 vagrant statusで確認すると稼働はしているようです

default running (virtualbox) The VM is running. To stop this VM, you can run `vagrant halt` to shut it down forcefully, or you can run `vagrant suspend` to simply suspend the virtual machine. In either case, to restart it again, simply run `vagrant up`.

1-2 vagrant ssh-configの結果は以下の通りです。

PS C:\Users\xxx\MyVagrant\MyCentOS> vagrant ssh-config Host default HostName 127.0.0.1 User vagrant Port 2222 UserKnownHostsFile /dev/null StrictHostKeyChecking no PasswordAuthentication no IdentityFile C:/Users/xxx/.vagrant.d/insecure_private_key IdentitiesOnly yes LogLevel FATAL

2.試してみたこと

2-1 Host NameとPortを127.0.0.1 : 2222で確認

イメージ説明

結果→タイムアウトで接続できない

2-2 Putty アンインストールして再度再インストール

結果→タイムアウトで接続できない

2-3 鍵の確認

C:\MyPath.vagrant\machines\default\virtualboxの中身を確認
イメージ説明

  →鍵に関する情報ファイルは、なさげでした

2-4 仮想化機能(Hyer-V)にチェックして再起動後実施

イメージ説明

    結果→タイムアウトで接続できない

以上の様な状況で行き詰っております。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答3

0

基本的には、powershell から vagrant ssh できなければ、特別な設定をしていない限りは putty からも ssh できません。
正常に vagrant up できているようなので外しているかもしれませんが、既に付いている回答とは別の視点で。

・「仮想化機能(Hyer-V)にチェックして再起動後実施」と書かれていますが、virtualboxを使っているのですよね?
virtualbox を使う場合には Hyper-Vはオフにすべきですので調べてみてください。

・SSを見ると Hyper-Vプラットフォームにチェックを入れることができないように見えますが、BIOS設定の仮想化支援機能は有効になっていますか?

投稿2018/11/12 07:10

ssasaki

総合スコア1167

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Yasu0421

2018/11/12 07:49

ご回答ありがとうございます。 仮想化機能は、試しに実施してみただけでして、現在はオフにしております。 BIOS側の設定は、かなり前から見ていたのですが、 メニュー自体に仮想化支援を有効にする項目がみあたらないのです。 未対応?でしょうか?
ssasaki

2018/11/15 05:56

解決済みのようですが、Windows10環境だとタスクマネージャーのパフォーマンスタブの "CPU" を表示すると、下の方に「仮想化」という項目があり、有効になっている際には「有効」と表示されるようです。 仮想化支援項目のないマシンは使ったことがないので、その場合どうなるのかは分かりませんが。。
guest

0

ベストアンサー

vargrant ssh ではつながるのですか?
・Windowsのセキュリティソフト、ファイアウォールが稼働している場合は、問題切り分けのため一時的にOFFにしてみてください。
・192.168.33.10 ポート22 で試すとどうなりますか。
・鍵ファイルが間違っているだけだとその旨のエラーが発生するので、タイムアウト(無反応)とは挙動が違うと思います。
・C:/Users/xxx/.vagrant.d/insecure_private_key が鍵ファイルのようですが、これは存在しないですか?

====
127.0.0.1が疎通できないというのは
vagrantがポートフォーワーディングの設定に失敗しているか、
127.0.0.1のネットワーク関係の問題な様に思います。
(なので192.168.33.10でsshできるか知りたかった。)

あと、ちょっと気になっているのが鍵ファイルの場所と名前です。
私の環境では C:/xxx/xxx/.vagrant/machines/default/virtualbox/private_key
のようになります。

まだ解決しないようでしたら、もう一度initからやり直してみてはいかがでしょうか。

私は、はじめてvagrant upをしたとき、
セキュリティソフトとファイアウオールをOFFにしないと
ネットワークの設定あたりでこけたので、OFFにしてからやってみてください。
あと、今格闘しているboxは止めてから実施ください(vagrant halt)

Windows10 64bit
Vagrant 2.2.0
VBoxManage バージョン 5.2.20
(vagrantとvirtuallboxのバージョンの相性が悪いとだめというのもよくあるみたいなので
参考にしてください。)

Windows10の管理者権限を付与したユーザで、
WindowsPowershellから、
mkdir centos6
cd .\centos6
vagrant init bento/centos-6.8
vagrantfileの
config.vm.network "private_network", ip: "192.168.33.10"
のコメントを外して(有効にして)保存
vagrant up

これで、私のPCではvagrant sshが普通にできました。

投稿2018/11/12 01:46

編集2018/11/13 04:03
taka-saan

総合スコア665

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Yasu0421

2018/11/12 02:14

ご回答いただきありがとうございます。 上記順に回答致します。 ・PowerShell上から"vagrant ssh"するとプロンプト帰らない状況 ・一旦OFFにしています ・こちらでデフォルト値でして、この設定でNGでしたので、  192.168.33.10にて試した次第です。(説明不足で申し訳ございません) ・そうですかぁ ・ご指定のフォルダに鍵ファイルは存在しております
taka-saan

2018/11/12 03:02

まずはvagrant ssh ができないことには、PuTTYでもできません。 vagrantfile を192.168.33.10に変更した後、vagrant upをしたと思いますが、 その際エラーがでてませんでしたか?
taka-saan

2018/11/12 04:10

> 「こちらでデフォルト値でして、この設定でNGでした」 というのは何をしてどのようにNGだったのでしょうか。もう少し詳しく教えてください。 私が確認していただきたかったのは、今、vagrantfileが192.168.33.10で設定されているので、VMはそのままで、PuTTYの接続情報の方を 192.168.33.10 ポート22 でログインできませんか? ということです。
Yasu0421

2018/11/13 04:08

詳細な対応説明いただき、誠にありがとうございます。 そうですね、私も通常記載されている鍵ファイルと保管先が異なっているのに 違和感を感じていました。 ご回答いただいた内容で、トライしてみます。
Yasu0421

2018/11/13 06:50

どうも、鍵が正常に作成されていないことが原因のようでした。 本来の手順ではございませんが、 `http://tauplank.hatenablog.com/entry/2016/10/23/153728` や `https://qiita.com/skjune12/items/ed873a120f8461a57e20` を参考にして、なんとかアクセスできるようになりました。 どうもありがとうございました。
guest

0

bentoCentos6.8の初期設定だと思われますが、

IdentityFile C:/Users/xxx/.vagrant.d/insecure_private_key

に鍵ファイルの場所が記載されていますので、そちらの鍵ファイルを使用して
SSH接続を試してみてください。

投稿2018/11/12 01:25

編集2018/11/12 01:26
ozwind918

総合スコア1140

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Yasu0421

2018/11/12 02:27

ご回答ありがとうございます。 上記、1-2でしめしておりますSSH接続情報のところには、 鍵ファイルが存在しておりますが、SSH接続できない状況です。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問