首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Windows主机上使用Vagrant运行Chef食谱: SSH问题

在Windows主机上使用Vagrant运行Chef食谱: SSH问题
EN

Stack Overflow用户
提问于 2012-06-30 04:21:51
回答 2查看 1.5K关注 0票数 2

我使用Vagrant在Windows主机上创建了一个CentOS虚拟机并连接到它,到目前为止一切正常。

接下来,我想使用Chef在创建的VM上配置堆栈。我尝试使用本地目录食谱以及提供食谱的urls,但可能失败了,因为它不能ssh到guest box,如error所示:

SSH authentication failed! This is typically caused by the public/private keypair for the SSH user not being properly set on the guest VM. Please verify that the guest VM is setup with the proper public key, and that the private key path for Vagrant is setup properly as well.

所以我的第一个问题是:

1)如何确保SSH在Windows主机中启动来宾操作系统的同一窗口中工作,以便所有脚本都能正常执行?

现在,当我在vagrantfile中的下面一行注释时

代码语言:javascript
复制
config.ssh.username = "root"

上面的错误消失了,但我得到了另一个错误:

The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed!

mount -t vboxsf -o uid=id -u vagrant,gid=id -g vagrant v-csr-2 /tmp/vagrant-chef-1/chef-solo-2/roles

这是因为用户流浪者在box上没有足够的访问权限,这是我的第二个问题:

2)如何指示Vagrant以sudo或su访问权限运行所有命令?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-01-25 17:12:59

下面是我是如何让SSH工作的:

安装cygwin (http://www.cygwin.com/)

从cygwin中设置openssh

添加~/.ssh/id_rsa_vagrant

here下载

修改~/.ssh/config

主机本地主机IdentityFile ~/.ssh/id_rsa_vagrant

修改ssh目录的权限

chmod 600 ~/.ssh/*

一切都应该运行得很好。

票数 1
EN

Stack Overflow用户

发布于 2012-09-26 05:08:24

我找到了一种方法,可以使用批处理文件和Windows中的相同命令提示符窗口连接到VM。

下面是一些步骤:

  • 您需要在同一台计算机上安装putty。
  • 您需要在以下批处理脚本中配置putty可执行文件的路径
  • 使用批处理文件连接到您的计算机

下面是批处理文件:

@echo off REM REM This is a replacement for the "vagrant ssh" command on Windows REM (since "vagrant ssh" doesn't actually work on Windows). REM REM PuTTY must be installed. If it is not installed in REM "C:\Program Files (x86)\PuTTY" then set the PUTTY_DIR environment REM to point to the installed location. REM REM As with any vagrant command this should be executed in the directory REM containing the Vagrantfile. REM

setlocal enableextensions

if "%PUTTY_DIR%" == "" ( REM Default location of PuTTY if the Windows installer is used. set "PUTTY_DIR=C:\Program Files (x86)\PuTTY" )

if not exist "%PUTTY_DIR%" ( echo ERROR: PuTTY not found. echo Install PuTTY or check setting of PUTTY_DIR. goto end )

for /F "tokens=1,2" %%A in ('vagrant ssh-config') do ( if "%%A" == "HostName" ( set VagrantHostName=%%B ) if "%%A" == "Port" ( set VagrantPort=%%B ) if "%%A" == "User" ( set VagrantUser=%%B ) if "%%A" == "IdentityFile" ( set IdentityFile=%%B ) )

if "%VagrantHostName%" == "" ( goto end )

if exist %IdentityFile%.ppk ( set "VGPUTTY_OPTIONS=%VGPUTTY_OPTIONS% -i %IdentityFile%.ppk" ) else ( echo. echo TIP: For password-free Vagrant VM login use PuTTYGen to generate echo this file: %IdentityFile%.ppk echo from file: %IdentityFile% echo. )

start "%VagrantHostName%:%VagrantPort%" "%PUTTY_DIR%\PuTTY.exe" %VGPUTTY_OPTIONS% %VagrantUser%@%VagrantHostName% %VagrantPort%

:end

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11268472

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档