Boot2docker: SSH into boot2docker vm as root

Created on 25 Sep 2014  路  7Comments  路  Source: boot2docker/boot2docker

I'm trying to setup OpenSSH on boot2docker to support ssh'ing as root from OS X to enable sshfs-fuse to mount persistent docker volumes in /mnt.

Right now, I can do: $ ssh docker@boot2docker and that works just fine, but since the /mnt directory is all root, I cannot actually mount the persistent volumes.

I can configure /usr/local/etc/ssh/sshd_config to PermitRootLogin yes and PermitRootLogin without-password, but it still doesn't work because I need to create an ssh key for the root user and add my OS X public key to /root/.ssh/authorized_keys. The issue there is that /root/.ssh gets wiped out upon restarting the vm.

Any ideas / suggestions greatly appreciated.

question

Most helpful comment

Login via ssh as dockeruser with tcuser password. Then just run sudo su root.

All 7 comments

https://github.com/boot2docker/boot2docker-cli/pull/247 contains all the steps needed to use sshfs to mount your host's dirs into the vm :)

@SvenDowideit That doesn't answer the original question.

ssh root@localhost -p 2222 asks me a root password and am sure it's saying give me root password root@localhost inside boot2docker vm.

no, true, it doesn't answer the direct question, because there are better ways to achieve the desired result (i hope)

I find a way to do that. First please login as docker user. Then create the password of the root using command 'sudo passwd root'. At the end, you can switch to root user with 'su - root'. It works in my machine.

Login via ssh as dockeruser with tcuser password. Then just run sudo su root.

I also can change the password of root user by 'sudo passwd root'. Is it expected? anyway, it solved my problem.

I'm interested in using this to implement the docker-machine mount feature for Windows (see docker/machine#4014). The SSHFS+FUSE approach is packaged up in an SSHFS binary for Windows here.

However I'm unable to use it with the docker user since it has no access to the volume folders, and Dokan doesn't have the allow_root feature. Once I ssh in and do the sudo passwd root hack (plus enable PermitRootLogin in the sshd config), I am able to mount all remote volumes as local drives.

If the root login restriction is removed (or docker is granted access to the volumes), this can be packaged into an implementation of the docker-machine mount feature for Windows.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mclarkson picture mclarkson  路  5Comments

ghost picture ghost  路  14Comments

kianmeng picture kianmeng  路  8Comments

rafaelsoaresbr picture rafaelsoaresbr  路  5Comments

ovidiubuligan picture ovidiubuligan  路  7Comments