030*_*030 9 ssh virtualbox authentication virtual-machine vagrant
Vagrant Up 期间身份验证失败,而 vagrant ssh 和 ssh vagrant@localhost -p2222 有效
我想在启动时使用 Vagrant 执行一个 shell 脚本。Vagrant 无法进行身份验证,而 VM 已使用vagrant up以下方式启动:
c:\temp\helloworld>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'helloworld'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: helloworld_default_1398419922203_60603
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Error: Connection timeout. Retrying...
default: Error: Authentication failure. Retrying...
default: Error: Authentication failure. Retrying...
default: Error: Authentication failure. Retrying...
default: Error: Authentication failure. Retrying...
...
Run Code Online (Sandbox Code Playgroud)
执行后CTRL + C,可以使用vagrant ssh和ssh vagrant@localhost -p2222
流浪文件
我使用默认的 Vagrantfile,我只更改了主机名:
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "helloworld"
...
Run Code Online (Sandbox Code Playgroud)
流浪版
c:\temp\helloworld>vagrant --version
Vagrant 1.5.1
Run Code Online (Sandbox Code Playgroud)
题
如何使用vagrant up?
这个问题是因为 Vagrant 盒子上没有公钥。以下两个选项之一可以解决该问题。
第一个选项是使用 Packer 创建一个新的 Vagrant box。将以下代码段添加到 json 文件并构建 Vagrant 框。
"provisioners": [{
"type": "shell",
"scripts": [
"scripts/vagrant.sh"
]
}]
Run Code Online (Sandbox Code Playgroud)
这个vagrant 脚本的内容如下:
#!/bin/bash
yum install wget -y
mkdir /home/vagrant/.ssh
wget --no-check-certificate \
'https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub' \
-O /home/vagrant/.ssh/authorized_keys
chown -R vagrant /home/vagrant/.ssh
chmod -R go-rwsx /home/vagrant/.ssh
Run Code Online (Sandbox Code Playgroud)
第二个选项是在运行了此处vagrant package指定的以下命令后重新打包 ( ) Vagrant 框:
mkdir -p /home/vagrant/.ssh
wget --no-check-certificate https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub -O /home/vagrant/.ssh/authorized_keys
chmod 0700 /home/vagrant/.ssh
chmod 0600 /home/vagrant/.ssh/authorized_keys
chown -R vagrant /home/vagrant/.ssh
Run Code Online (Sandbox Code Playgroud)
首先,尝试:查看您的机器配置中的vagrant 私钥
$ vagrant ssh-config
Run Code Online (Sandbox Code Playgroud)
例子:
$ vagrant ssh-config
Host default
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile C:/Users/konst/.vagrant.d/insecure_private_key
IdentitiesOnly yes
LogLevel FATAL
Run Code Online (Sandbox Code Playgroud)
http://docs.vagrantup.com/v2/cli/ssh_config.html
其次,做:用你自己的系统私钥的内容 更改文件insecure_private_key的内容
| 归档时间: |
|
| 查看次数: |
20907 次 |
| 最近记录: |