在基本初始化时无法使用Vagrant SSH密钥使用连接(authorized_keys权限问题)

时间:2016-09-06 13:27:11

标签: ssh centos vagrant virtualbox

我试图唤醒基本虚拟机bento/centos-67

$ vagrant version
Installed Version: 1.8.5
Latest Version: 1.8.5

You're running an up-to-date version of Vagrant!

$ vagrant init bento/centos-6.7; vagrant up --provider virtualbox; vagrant up
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'bento/centos-6.7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/centos-6.7' is up to date...
==> default: Setting the name of the VM: bento_default_1473166306806_14580
==> 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: 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:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...

但与此同时,我可以使用vagrant ssh密码vagrant

那么,有什么不对?

关联问题:#1

(还向chef报告了问题)

修正

问题是:~/.ssh/authorized_keys文件的公钥具有644权限,但必须为600

$ ssh vagrant@127.0.0.1 -p 2200 # use password "vagrant"
[vagrant@localhost ~]$ chmod 600 ~/.ssh/authorized_keys

现在vagrant ssh可以不用询问就可以使用。

问题是为什么它不能从盒子里工作?出了什么问题?我教过它如何正确定义authorized_keys文件? OO

这可能与the vagrant bug有关。

1 个答案:

答案 0 :(得分:1)

这绝对是你要链接的Vagrant bug而不是Bento盒子。我是Bento盒子维护者,我们已经在管道中退回到Vagrant 1.8.4。