Vagrant SSH身份验证方法:在VirtualBox中调用登录名的私钥

Vagrant SSH身份验证方法:在VirtualBox中调用登录名的私钥,vagrant,Vagrant,我和Windows上的流浪汉有问题。运行vagrant up,它会在SSH身份验证时停止,并且似乎正在VirtualBox控制台中请求SSH登录凭据 Windows 8.1控制台输出 C:\Users\leke\dev\Learning PHP 7>vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Checking if box 'ubuntu/trusty32' i

我和Windows上的流浪汉有问题。运行
vagrant up
,它会在SSH身份验证时停止,并且似乎正在VirtualBox控制台中请求SSH登录凭据

Windows 8.1控制台输出

C:\Users\leke\dev\Learning PHP 7>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/trusty32' is up to date...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 80 (guest) => 8080 (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:22
    default: SSH username: vagrant
    default: SSH auth method: private key
Oracle VM VirtualBox输出

Ubuntu 14.04.5 LTS vagrant-ubuntu-trusty-32 tty1 
vagrant-ubuntu-trusty-32 login: 
如果我使用私钥身份验证,我不需要输入凭据(我不知道)

这是我的设置,它取自《学习PHP7》一书

流浪档案

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "ubuntu/trusty32"
  config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1", id: 'ssh'
  config.vm.provision "shell", path: "provisioner.sh"
end
供应员

#!/bin/bash

sudo apt-get install python-software-properties -y
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php -y
sudo apt-get update
sudo apt-get install php7.0 php7.0-fpm php7.0-mysql -y
sudo apt-get --purge autoremove -y
sudo service php7.0-fpm restart

sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
sudo apt-get -y install mysql-server mysql-client
sudo service mysql start

sudo apt-get install nginx -y
sudo cat > /etc/nginx/sites-available/default <<- EOM
server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /vagrant;
    index index.php index.html index.htm;

    server_name server_domain_or_IP;

    location / {
        try_files \$uri \$uri/ /index.php?\$query_string;
    }

    location ~ \.php\$ {
        try_files \$uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)\$;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
        include fastcgi_params;
    }
}
EOM
sudo service nginx restart
给了我另一个问题。当我更改端口时,它要么再次向我显示此消息,要么显示原始问题

C:\Users\leke\dev\Learning PHP 7>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/trusty32'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/trusty32' is up to date...
==> default: A newer version of the box 'ubuntu/trusty32' is available! You currently
==> default: have version '20170502.0.0'. The latest is version '20170504.0.0'. Run
==> default: `vagrant box update` to update.
==> default: Setting the name of the VM: LearningPHP7_default_1494189218317_29456
==> default: Clearing any previously set forwarded ports...
Vagrant cannot forward the specified ports on this VM, since they
would collide with some other application that is already listening
on these ports. The forwarded port to 3344 is already in use
on the host machine.

To fix this, modify your current project's Vagrantfile to use another
port. Example, where '1234' would be replaced by a unique host port:

  config.vm.network :forwarded_port, guest: 80, host: 1234

Sometimes, Vagrant will attempt to auto-correct this for you. In this
case, Vagrant was unable to. This is usually because the guest machine
is in a state which doesn't allow modifying port forwarding. You could
try 'vagrant reload' (equivalent of running a halt followed by an up)
so vagrant can attempt to auto-correct this upon booting. Be warned
that any unsaved work might be lost.

我见过这个。对我来说,这是一个事实,虚拟盒没有被旋转起来“电缆连接”。您可以在“设置>网络>高级”中检查此项。

将此添加到您的文件应该可以解决该问题

config.vm.provider'virtualbox'do | vb|
vb.customize['modifyvm',:id'--cableconnected1','on']
结束

对我有效的解决方案:
  • 重新安装virtualbox和vagrant

  • 以管理员运行方式打开Windows CMD

    bcdedit /set hypervisorlaunchtype off
    
  • 重启电脑


如果你可以连接到虚拟机,你能检查一下“/home/vagrant/.ssh”上的权限吗?嗨,
.ssh
的权限是
drwx------
所有者和组是vagrant。你能重新加载
vagrant吗?请注意,这将丢弃VMYes中的任何状态,我可以重新加载,但它会卡在私钥部分(与原始问题一样)。
bcdedit /set hypervisorlaunchtype off