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

"Permission denied" ssh errors on accessing unit-state.db #113

Open
sed-i opened this issue Dec 6, 2023 · 3 comments
Open

"Permission denied" ssh errors on accessing unit-state.db #113

sed-i opened this issue Dec 6, 2023 · 3 comments

Comments

@sed-i
Copy link

sed-i commented Dec 6, 2023

Issue

show-stored errors out,

$ jhack show-stored cos-proxy/0                       
ERROR:jhack:failed to fetch db; command ['juju', 'scp', 'cos-proxy/0:/var/lib/juju/agents/unit-cos-proxy-0/charm/.unit-state.db', '/home/ubuntu/snap/jhack/235/unit-state-otlo29cu.db'] exited with 1
failed to fetch db; aborting. b'ERROR exit status 1 (scp: /var/lib/juju/agents/unit-cos-proxy-0/charm/.unit-state.db: Permission denied)\n'

because of file permissions:

$ juju ssh cos-proxy/0 ls -la /var/lib/juju/agents/unit-cos-proxy-0/charm/.unit-state.db
-rw------- 1 root root 20480 Dec  6 17:58 /var/lib/juju/agents/unit-cos-proxy-0/charm/.unit-state.db

Solution attempts

ssh-ing with root doesn't work,

$ juju ssh root@cos-proxy/0 hexdump /var/lib/juju/agents/unit-cos-proxy-0/charm/.unit-state.db
root@10.41.168.28: Permission denied (publickey).

but a sudo helps

$ juju ssh cos-proxy/0 sudo hexdump /var/lib/juju/agents/unit-cos-proxy-0/charm/.unit-state.db
0000000 5153 694c 6574 6620 726f 616d 2074 0033
0000010 0010 0101 4000 2020 0000 0900 0000 0500
...
Connection to 10.41.168.28 closed.

Not sure to translate this to a juju scp command, but perhaps could pipe stdout instead?

Environment

  • jhack latest/stable 0.3.19.1.1 2023-09-01
  • Juju 3.1.6 on Ubuntu 22.04 vm (multipass).
@sed-i
Copy link
Author

sed-i commented Dec 6, 2023

On jhack (edge) 0.3.23 there's a different error:

jhack show-stored cos-proxy/0
Traceback (most recent call last):
  File "/snap/jhack/266/bin/jhack", line 8, in <module>
    sys.exit(main())
  File "/snap/jhack/266/lib/python3.8/site-packages/jhack/main.py", line 58, in main
    from jhack.scenario.snapshot import snapshot
  File "/snap/jhack/266/lib/python3.8/site-packages/jhack/scenario/snapshot.py", line 28, in <module>
    from jhack.scenario.utils import JujuUnitName
  File "/snap/jhack/266/lib/python3.8/site-packages/jhack/scenario/utils.py", line 6, in <module>
    from scenario.scripts.errors import InvalidTargetUnitName
ModuleNotFoundError: No module named 'scenario.scripts'

@PietroPasotti
Copy link
Collaborator

I'm working on this, I think the issue has appeared on some recent juju version (did the permissions change on the charm files at some point I recall?)

the importerror has been fixed in the meantime, the ssh issue persists.

@PietroPasotti PietroPasotti changed the title "Permission denied" for show-stored on machine charm "Permission denied" ssh errors on jhack commands using juju scp and juju ssh Jan 17, 2024
@PietroPasotti PietroPasotti changed the title "Permission denied" ssh errors on jhack commands using juju scp and juju ssh "Permission denied" ssh errors on accessing unit-state.db Jan 17, 2024
@Zvirovyi
Copy link

Zvirovyi commented May 8, 2024

Have the same issue on juju 3.5.0-genericlinux-amd64 (lxd) and jhack 0.4.0.25.4 (rev 337 from latest/stable):

ERROR:jhack:failed to fetch db; command ['juju', 'scp', 'postgresql/0:/var/lib/juju/agents/unit-postgresql-0/charm/.unit-state.db', '/home/zvirovyi/snap/jhack/337/unit-state-gz7m_i0i.db'] exited with 1
failed to fetch db; aborting. b'ERROR exit status 1 (scp: /var/lib/juju/agents/unit-postgresql-0/charm/.unit-state.db: Permission denied)\n'

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

3 participants