Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ShellDriver.put_ssh_key not working on read-only filesystem #93

Closed
rohieb opened this issue May 22, 2017 · 0 comments
Closed

ShellDriver.put_ssh_key not working on read-only filesystem #93

rohieb opened this issue May 22, 2017 · 0 comments

Comments

@rohieb
Copy link
Contributor

rohieb commented May 22, 2017

Doing ShellDriver.put_ssh_key() on a read-only file system only results in a stacktrace for me:

   INFO: Key not on target, mounting...
Traceback (most recent call last):
  File "test-xmodem.py", line 14, in <module>
    sd.put_ssh_key("../projectroot/root/.ssh/development_rsa.pub")
  File "/ptx/work/dude/WORK_B/rhi/realtimeci-DistroKit/labgrid-tests/env/lib/python3.5/site-packages/labgrid-0.1.1.dev1+g0897126-py3.5.egg/labgrid/binding.py", line 87, in wrapper
    return func(self, *_args, **_kwargs)
  File "/ptx/work/dude/WORK_B/rhi/realtimeci-DistroKit/labgrid-tests/env/lib/python3.5/site-packages/labgrid-0.1.1.dev1+g0897126-py3.5.egg/labgrid/driver/shelldriver.py", line 206, in put_ssh_key
    self._put_ssh_key(key)
  File "/ptx/work/dude/WORK_B/rhi/realtimeci-DistroKit/labgrid-tests/env/lib/python3.5/site-packages/labgrid-0.1.1.dev1+g0897126-py3.5.egg/labgrid/step.py", line 192, in wrapper
    _result = func(*_args, **_kwargs)
  File "/ptx/work/dude/WORK_B/rhi/realtimeci-DistroKit/labgrid-tests/env/lib/python3.5/site-packages/labgrid-0.1.1.dev1+g0897126-py3.5.egg/labgrid/driver/shelldriver.py", line 200, in _put_ssh_key
    self._run_check('mount --bind /tmp/keys ~/.ssh/authorized_keys')
  File "/ptx/work/dude/WORK_B/rhi/realtimeci-DistroKit/labgrid-tests/env/lib/python3.5/site-packages/labgrid-0.1.1.dev1+g0897126-py3.5.egg/labgrid/step.py", line 192, in wrapper
    _result = func(*_args, **_kwargs)
  File "/ptx/work/dude/WORK_B/rhi/realtimeci-DistroKit/labgrid-tests/env/lib/python3.5/site-packages/labgrid-0.1.1.dev1+g0897126-py3.5.egg/labgrid/driver/shelldriver.py", line 114, in _run_check
    raise ExecutionError(cmd)
labgrid.driver.exception.ExecutionError: mount --bind /tmp/keys ~/.ssh/authorized_keys

… which, in hindsight, is obvious, because on the target console:

root@DistroKit:~ mount --bind /tmp/keys ~/.ssh/authorized_keys
mount: mount point /root/.ssh/authorized_keys does not exist
root@DistroKit:~ mkdir ~/.ssh
mkdir: can't create directory '/root/.ssh': Read-only file system
root@DistroKit:~ mount -o rw,remount /
root@DistroKit:~ mkdir ~/.ssh
root@DistroKit:~ ls -la ~/.ssh
drwxr-xr-x    2 root     root             6 May 22  2017 .
drwxr-xr-x    3 1059     3000            26 May 22  2017 ..

On most freshly installed targets, /root/.ssh will most probably not exist, so on a read-only system, mkdir ~/.ssh in ShellDriver.py, line 179 will fail. I'm guessing the read-write mount is only done a few lines later with mount --bind, and if this works like I imagine, I think this issue could be solved by doing a mount --bind on the whole /root/ directory instead of only the authorized_keys file.

Emantor referenced this issue in Emantor/labgrid Nov 15, 2017
Previously we did a bind mount on just the authorized key file, this breaks if
we have a read only file system. Create a directory in /tmp and bind mount the
whole ~/.ssh directory instead.

Fixes #93

Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Emantor referenced this issue in Emantor/labgrid Nov 15, 2017
Previously we did a bind mount on just the authorized key file, this breaks if
we have a read only file system. Create a directory in /tmp and bind mount the
whole ~/.ssh directory instead.

Fixes #93

Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Emantor referenced this issue in Emantor/labgrid Nov 29, 2017
Previously we did a bind mount on just the authorized key file, this breaks if
we have a read only file system. Create a directory in /tmp and bind mount the
whole ~/.ssh directory instead.

Fixes #93

Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Emantor referenced this issue in Emantor/labgrid Nov 29, 2017
Previously we did a bind mount on just the authorized key file, this breaks if
we have a read only file system. Create a directory in /tmp and bind mount the
whole ~/.ssh directory instead.

Fixes #93

Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Emantor referenced this issue in Emantor/labgrid Nov 29, 2017
Previously we did a bind mount on just the authorized key file, this breaks if
we have a read only file system. Create a directory in /tmp and bind mount the
whole ~/.ssh directory instead.

Fixes #93

Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
jluebbe pushed a commit that referenced this issue Dec 6, 2017
Previously we did a bind mount on just the authorized key file, this breaks if
we have a read only file system. Create a directory in /tmp and bind mount the
whole ~/.ssh directory instead.

Fixes #93

Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant