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

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

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

VirtualBoxは、現在米オラクル社が開発している、 x86仮想化ソフトウェア・パッケージの一つです。

Vagrant

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

Q&A

3回答

6541閲覧

vagrant+virtualboxでputtyから接続できない

退会済みユーザー

退会済みユーザー

総合スコア0

VirtualBox

VirtualBoxは、現在米オラクル社が開発している、 x86仮想化ソフトウェア・パッケージの一つです。

Vagrant

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

0グッド

0クリップ

投稿2017/03/03 23:19

vagrant+virtualboxで仮想環境を作成して、puttyで接続しようとしていますが接続できないです。
(以前はputtyから接続できていたのですが、ある時いろいろとCドライブのファイルやフォルダを削除してしまったのでそれが原因かもしれません。)

Vagrantfileの中身です。

# -*- mode: ruby -*- # vi: set ft=ruby : # All Vagrant configuration is done below. The "2" in Vagrant.configure # configures the configuration version (we support older styles for # backwards compatibility). Please don't change it unless you know what # you're doing. Vagrant.configure(2) do |config| # The most common configuration options are documented and commented below. # For a complete reference, please see the online documentation at # https://docs.vagrantup.com. # Every Vagrant development environment requires a box. You can search for # boxes at https://atlas.hashicorp.com/search. config.vm.box = "centos7.1" # Disable automatic box update checking. If you disable this, then # boxes will only be checked for updates when the user runs # `vagrant box outdated`. This is not recommended. # config.vm.box_check_update = false # Create a forwarded port mapping which allows access to a specific port # within the machine from a port on the host machine. In the example below, # accessing "localhost:8080" will access port 80 on the guest machine. # config.vm.network "forwarded_port", guest: 80, host: 8080 # Create a private network, which allows host-only access to the machine # using a specific IP. config.vm.network "private_network", ip: "192.168.33.11" # Create a public network, which generally matched to bridged network. # Bridged networks make the machine appear as another physical device on # your network. # config.vm.network "public_network" # Share an additional folder to the guest VM. The first argument is # the path on the host to the actual folder. The second argument is # the path on the guest to mount the folder. And the optional third # argument is a set of non-required options. # config.vm.synced_folder "../data", "/vagrant_data" # Provider-specific configuration so you can fine-tune various # backing providers for Vagrant. These expose provider-specific options. # Example for VirtualBox: # # config.vm.provider "virtualbox" do |vb| # # Display the VirtualBox GUI when booting the machine # vb.gui = true # # # Customize the amount of memory on the VM: # vb.memory = "1024" # end # # View the documentation for the provider you are using for more # information on available options. # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies # such as FTP and Heroku are also available. See the documentation at # https://docs.vagrantup.com/v2/push/atlas.html for more information. # config.push.define "atlas" do |push| # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" # end # Enable provisioning with a shell script. Additional provisioners such as # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the # documentation for more information about their specific syntax and use. # config.vm.provision "shell", inline: <<-SHELL # sudo apt-get update # sudo apt-get install -y apache2 # SHELL end

vagrant upすると下記のようなメッセージが出力されます。

Bringing machine 'default' up with 'virtualbox' provider... ==> default: Clearing any previously set forwarded ports... ==> default: Fixed port collision for 22 => 2222. Now on port 2200. ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat default: Adapter 2: hostonly ==> default: Forwarding ports... default: 22 (guest) => 2200 (host) (adapter 1) ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2200 default: SSH username: vagrant default: SSH auth method: private key ==> default: Machine booted and ready! ==> default: Checking for guest additions in VM... default: The guest additions on this VM do not match the installed version of default: VirtualBox! In most cases this is fine, but in rare cases it can default: prevent things such as shared folders from working properly. If you see default: shared folder errors, please make sure the guest additions within the default: virtual machine match the version of VirtualBox you have installed on default: your host and reload your VM. default: default: Guest Additions Version: 4.3.30 default: VirtualBox Version: 5.1 ==> default: Configuring and enabling network interfaces... ==> default: Mounting shared folders... default: /vagrant => C:/vagrant_folders/oracle ==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision` ==> default: flag to force provisioning. Provisioners marked to run always will still run.

vagrant upしてからputtyで192.168.33.11に接続すると何も表示されないまま、タイムアウトエラーになります。

putty設定
putty接続中
タイムアウトエラー

何が原因なのでしょうか?
正常に接続できるようにするにはどうすればよいでしょうか。

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

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

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

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

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

turbgraphics200

2017/03/06 10:19

Windowおよび、Vagrantのバージョンを記載してください。
guest

回答3

0

解決方法(2)

鍵を再作成する本来の対応です。
Vagrantfileがあるフォルダ(=vagrant upを行うフォルダ)を C:\YourPath\ とします。

  1. Puttyに同封されているputtygen.exe を起動します。
  2. メニューの [File] > [load private key] を選択
  3. ファイル選択の画面が開くので、右下のセレクトボックスを All files(.) にして

C:\YourPath.vagrant\machines\default\virtualbox\private_key
を開きます。
0. 元の画面に戻ったら右下寄りにある [Save private key]を押します。
パスフレーズ無しでもいいかと聞かれますが[OK]を押して大丈夫です。
0. 保存先選択の画面が開くので、右下のセレクトボックスを All files(.) にして
または任意のパスに {任意の名前}.ppk として保存します
例)
C:\YourPath.vagrant\machines\default\virtualbox\private_key.ppk
C:\Users\YourName\centos7_1_key.ppk

  1. putty の接続設定で

[接続]> [SSH]> [認証] のタブを開き、
その中の[認証パラメータ]の [認証のためのプライベートキーファイル]に
先のppkファイルを指定
0. 設定を保存し、接続できるか試します。

投稿2017/03/06 09:59

clickmaker

総合スコア200

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

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

退会済みユーザー

退会済みユーザー

2017/05/13 10:17

すいません、どちらの方法もタイムアウトエラーとなってしまいました。
guest

0

Vagrant は公開鍵認証を行うのでおそらく
Putty用の鍵を消してしまったのではと思います。

解決方法(1)
パスワードログインをONにする暫定対応です

Vagrantfileがあるフォルダ(=vagrant upを行うフォルダ)を C:\YourPath\ とします。

[コマンドプロンプト] > cd C:\YourPath\ > dir .vagrant\machines\default\virtualbox\ ※ private_keyファイルがあるのを確認 > vagrant ssh

SSHログインできるはず。できたら
(できなかったらVirtualBoxのターミナルから直接でもOKです)

$ sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak $ sudo vi /etc/ssh/sshd_config ... PasswordAuthentication yes ※ yesにする ... $ sudo service sshd restart

putty で
ID: vagrant
Passoword: vagrant
Host: 192.168.33.11
Port: 22
でログインできるか試します。

投稿2017/03/06 09:43

clickmaker

総合スコア200

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

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

0

すみません。メッセージの下記を見逃していました。

default: SSH address: 127.0.0.1:2200 default: SSH username: vagrant default: SSH auth method: private key

puttyでIPアドレス部分を127.0.0.1に変更して、Port番号を2200でお試しください。

投稿2017/03/04 00:23

編集2017/03/04 10:39
nagaetty

総合スコア1106

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

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

退会済みユーザー

退会済みユーザー

2017/03/04 02:08

ネットワークエラーになりました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問