Vagrant ssh 链接不上的处理方法

通过

vagrant ssh

命令链接上面虚拟机,执行下面命令,reboot虚拟机,问题应该就解决了

sudo /home/vagrant/vagrant.sh

reboot

/home/vagrant/vagrant.sh 内容如下:

# vim /home/vagrant/vagrant.sh

# Vagrant specific
date > /etc/vagrant_box_build_time

# Add vagrant user
/usr/sbin/groupadd vagrant
/usr/sbin/useradd vagrant -g vagrant -G wheel
echo "vagrant"|passwd --stdin vagrant
echo "vagrant        ALL=(ALL)       NOPASSWD: ALL" >> /etc/sudoers.d/vagrant
chmod 0440 /etc/sudoers.d/vagrant

# Installing vagrant keys
mkdir -pm 700 /home/vagrant/.ssh
wget --no-check-certificate 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub' -O /home/vagrant/.ssh/authorized_keys
chmod 0600 /home/vagrant/.ssh/authorized_keys
chown -R vagrant /home/vagrant/.ssh

# Customize the message of the day
echo 'Welcome to your Vagrant-built virtual machine.' > /etc/motd

关闭防火墙、启动sshd命令

systemctl start mysqld.service
systemctl enable mysqld.service

systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl stop  iptables.service
systemctl disable iptables.service

systemctl enable sshd.service
systemctl enable crond.service
systemctl enable messagebus.service

systemctl restart  sshd.service

转载于:https://my.oschina.net/leeyisoft/blog/870550

更多推荐