vagrant provision ssh 问题
vagrant provision ssh issue
我有 vagrant 运行 scotchbox。我最近尝试将 id_rsa.pub 添加到 /vagrant/home/.ssh,希望能够在不输入密码的情况下使用 ssh。一旦我这样做了,它的行为是一样的,所以我将其删除。现在我在配置中添加了另一个站点,现在我不能做 vagrant provision,因为它给了我以下错误。
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.
这是我从 vagrant ssh-config 得到的
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile "/Users/username/.vagrant.d/boxes/scotch-VAGRANTSLASH-box/3.0/virtualbox/vagrant_private_key"
IdentitiesOnly yes
LogLevel FATAL
这是我的 vagrant 文件。
Vagrant.configure("2") do |config|
config.vm.box = "scotch/box"
config.vm.network "private_network", ip: "192.168.10.10"
config.vm.hostname = "scotchbox"
config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=775", "fmode=664"]
config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
end
# Optional NFS. Make sure to remove other synced_folder line too
#config.vm.synced_folder ".", "/var/www", :nfs => { :mount_options => ["dmode=777","fmode=666"] }
config.vm.provision "shell", inline: <<-SHELL
## Only thing you probably really care about is right here
DOMAINS=("site1.dev" "site2.dev" "site3.dev" "site4.dev" "site5.dev" "ai.d$
## Loop through all sites
for ((i=0; i < ${#DOMAINS[@]}; i++)); do
## Current Domain
DOMAIN=${DOMAINS[$i]}
echo "Creating directory for $DOMAIN..."
mkdir -p /var/www/$DOMAIN/public
echo "Creating vhost config for $DOMAIN..."
sudo cp /etc/apache2/sites-available/scotchbox.local.conf /etc/apache2/si$
echo "Updating vhost config for $DOMAIN..."
sudo sed -i s,scotchbox.local,$DOMAIN,g /etc/apache2/sites-available/$DOM$
sudo sed -i s,/var/www/public,/var/www/$DOMAIN/public,g /etc/apache2/site$
echo "Enabling $DOMAIN. Will probably tell you to restart Apache..."
sudo a2ensite $DOMAIN.conf
done
SHELL
end
我在执行 vagrant up 时也遇到身份验证错误,直到它超时,但 box 仍然启动并工作,我可以使用密码 ssh 进入它。
我查看了许多其他问题并尝试了一些方法,但似乎没有任何解决办法。理想情况下,我想通过 ssh 使用密钥,但会安顿下来只是为了返回,所以我可以提供它并且必须使用密码登录。
谢谢
我通过在我的 Vagrantfile 中设置以下内容来解决这个问题,以使用 vagrant 在初始化时创建的 ssh 密钥。
config.ssh.private_key_path = "/pathtovagrantfolder/.vagrant/machines/default/virtualbox/private_key"
我有 vagrant 运行 scotchbox。我最近尝试将 id_rsa.pub 添加到 /vagrant/home/.ssh,希望能够在不输入密码的情况下使用 ssh。一旦我这样做了,它的行为是一样的,所以我将其删除。现在我在配置中添加了另一个站点,现在我不能做 vagrant provision,因为它给了我以下错误。
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.
这是我从 vagrant ssh-config 得到的
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile "/Users/username/.vagrant.d/boxes/scotch-VAGRANTSLASH-box/3.0/virtualbox/vagrant_private_key"
IdentitiesOnly yes
LogLevel FATAL
这是我的 vagrant 文件。
Vagrant.configure("2") do |config|
config.vm.box = "scotch/box"
config.vm.network "private_network", ip: "192.168.10.10"
config.vm.hostname = "scotchbox"
config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=775", "fmode=664"]
config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
end
# Optional NFS. Make sure to remove other synced_folder line too
#config.vm.synced_folder ".", "/var/www", :nfs => { :mount_options => ["dmode=777","fmode=666"] }
config.vm.provision "shell", inline: <<-SHELL
## Only thing you probably really care about is right here
DOMAINS=("site1.dev" "site2.dev" "site3.dev" "site4.dev" "site5.dev" "ai.d$
## Loop through all sites
for ((i=0; i < ${#DOMAINS[@]}; i++)); do
## Current Domain
DOMAIN=${DOMAINS[$i]}
echo "Creating directory for $DOMAIN..."
mkdir -p /var/www/$DOMAIN/public
echo "Creating vhost config for $DOMAIN..."
sudo cp /etc/apache2/sites-available/scotchbox.local.conf /etc/apache2/si$
echo "Updating vhost config for $DOMAIN..."
sudo sed -i s,scotchbox.local,$DOMAIN,g /etc/apache2/sites-available/$DOM$
sudo sed -i s,/var/www/public,/var/www/$DOMAIN/public,g /etc/apache2/site$
echo "Enabling $DOMAIN. Will probably tell you to restart Apache..."
sudo a2ensite $DOMAIN.conf
done
SHELL
end
我在执行 vagrant up 时也遇到身份验证错误,直到它超时,但 box 仍然启动并工作,我可以使用密码 ssh 进入它。
我查看了许多其他问题并尝试了一些方法,但似乎没有任何解决办法。理想情况下,我想通过 ssh 使用密钥,但会安顿下来只是为了返回,所以我可以提供它并且必须使用密码登录。
谢谢
我通过在我的 Vagrantfile 中设置以下内容来解决这个问题,以使用 vagrant 在初始化时创建的 ssh 密钥。
config.ssh.private_key_path = "/pathtovagrantfolder/.vagrant/machines/default/virtualbox/private_key"