2017-04-19 3 views
2

これはearlier questionへのフォローアップの質問です。私は同じVagrantfileを使用しましたが、必要とは思わない2行をコメントアウトしました。SSHをVagrant VMに追加することはできません(寄付者のSSHを使用しないでください)。

私はvagrant sshを使用せずに自分のバゲッジボックスにsshしようとしています。

Vagrantfile:

Vagrant.configure(2) do |config| 

    config.vm.provider "virtualbox" do |v| 
    v.memory = 6144 
    v.cpus = 2 
    v.name = "mb_vagrant" 
    end 

    config.vm.box = "ubuntu/trusty64" 

    config.vm.network :private_network, ip: "192.168.33.10" 

    config.ssh.forward_agent = true 

    # config.vm.provision :shell, path: "bootstrap.sh" 
    # config.vm.network :forwarded_port, host: 8001, guest: 8001 

end 

vagrant ssh-configからの出力:

Host default 
    HostName 127.0.0.1 
    User vagrant 
    Port 2222 
    UserKnownHostsFile /dev/null 
    StrictHostKeyChecking no 
    PasswordAuthentication no 
    IdentityFile "/Users/mbigras/Google Drive/tmp/chef-repo/.vagrant/machines/default/virtualbox/private_key" 
    IdentitiesOnly yes 
    LogLevel FATAL 
    ForwardAgent yes 

私は、次のコマンドを使用して、私のマシンにINGのsshを試してみた:

以下は私のVagrantfileとsshの設定情報があります
$ ssh -i "/Users/mbigras/Google Drive/tmp/chef-repo/.vagrant/machines/default/virtualbox/private_key" -p 2222 [email protected] 
ssh: connect to host 192.168.33.10 port 2222: Connection refused 

また、 another answerに記載されていますが、接続しようとする前に~/.ssh/known_hostsを削除しようとしました。しかし、それも動作しません:

$ rm ~/.ssh/known_hosts 
$ ssh -i "/Users/mbigras/Google Drive/tmp/chef-repo/.vagrant/machines/default/virtualbox/private_key" -p 2222 [email protected] 
ssh: connect to host 192.168.33.10 port 2222: Connection refused 

私はここで何が欠けていますか?

+0

16.04を使用する場合は[bento/ubuntu-16.04](https://atlas.hashicorp.com/bento/boxes/ubuntu-16.04)をおすすめします。 )彼らは標準のユーザー名を使用しているため:迷惑メール、パスワード: – mbigras

答えて

3

SSHサービスは、ゲストマシンの(すなわち:127.0.0.1)にバインドされているポートが、VMにまだ(デフォルトポートとして)ポート22でリッスンしています。 だから、あなたは127.0.0.1192.168.33.10またはのポートに接続する必要があります。すなわち:

$ ssh -i "<vagranfile-path>/.vagrant/machines/default/virtualbox/private_key" \ 
-p 22 [email protected] 

または

$ ssh -i "<vagranfile-path>/.vagrant/machines/default/virtualbox/private_key" \ 
-p 2222 [email protected] 

また、~/.ssh/known_hostsファイルを削除する必要はありません。次のオプションを追加すると、ホストの指紋チェックを避けることができます。-o UserKnownHostsFile=/dev/null

関連する問題