You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在boot2docker虚拟机中无法重启sshd服务的解决方法求助

Fixing SSHD Restart Issue on boot2docker (Windows 7 Host)

Hey there! Let's work through this SSH restart problem on your boot2docker VM. Since boot2docker is built on Tiny Core Linux, its service management and file structure work a bit differently from mainstream distros like Ubuntu or CentOS—here's how to get things sorted:

1. Ensure the Filesystem is Writable

Boot2docker uses a read-only root filesystem by default. Even if you already modified /usr/local/etc/ssh/sshd_config, double-check you have write access to make system changes:

sudo mount -o remount,rw /

This unlocks the filesystem so you can restart services and adjust permissions properly.

2. Use the Correct SSHD Restart Command

The service sshd restart command doesn't work on boot2docker. Instead, use the system's init script directly:

sudo /etc/init.d/sshd restart

You should see clear output confirming the service stops and starts (e.g., Stopping sshd... done, Starting sshd... done).

3. Fix Permissions for /var/lib/sshd

The permission denied error on /var/lib/sshd is likely blocking SSHD from starting. This directory needs to be owned by the sshd user with strict, secure permissions:

sudo chown sshd:sshd /var/lib/sshd
sudo chmod 700 /var/lib/sshd

This ensures SSHD can access its runtime files without permission conflicts.

4. Verify the SSHD Binary Location

You mentioned /usr/local/sbin/sshd wasn't found—boot2docker stores the SSHD binary at /usr/sbin/sshd. Confirm this with:

which sshd

If it returns /usr/sbin/sshd, that's the correct path. If not, you may need to reinstall the SSH package (though this is rare in pre-configured boot2docker environments).

5. Double-Check Critical sshd_config Settings

For PuTTY to connect successfully, make sure these key settings are enabled in /usr/local/etc/ssh/sshd_config:

PermitRootLogin yes  # Use "prohibit-password" if you prefer key-based auth, but "yes" for password login
PasswordAuthentication yes

Save the file after editing, then restart SSHD with the init script command from step 2.

6. Confirm Port Forwarding (For Windows Host Access)

Don't forget to set up port forwarding in your VM manager (VirtualBox/VMware): map a port on your Windows host (e.g., 2222) to the boot2docker VM's port 22. Then in PuTTY, connect to localhost:2222 using your boot2docker credentials.


内容的提问来源于stack exchange,提问作者Alice Delia

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 08:08:39