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

stanley_rsa is owned by root:root instead of stanley user in k8s #84

Closed
cmmdrdata opened this issue Sep 10, 2019 · 11 comments · Fixed by #219
Closed

stanley_rsa is owned by root:root instead of stanley user in k8s #84

cmmdrdata opened this issue Sep 10, 2019 · 11 comments · Fixed by #219
Labels
bug Something isn't working
Milestone

Comments

@cmmdrdata
Copy link

cmmdrdata commented Sep 10, 2019

in the st2client pod sudo su - stanley then try to login somewhere using stanley_rsa key. It won't work unless you are root or use sudo.

whoami
stanley
stanley@stackstorm-st2client-b96dd9f76-t9kjp:~$ ls -l ~stanley/.ssh/
total 0
lrwxrwxrwx 1 root root 18 Sep  9 20:35 stanley_rsa -> ..data/stanley_rsa
stanley@stackstorm-st2client-b96dd9f76-t9kjp:~$ ssh undercloud.admin -i ~stanley/.ssh/stanley_rsa
The authenticity of host 'undercloud.admin' (10.75.163.57)' can't be established.
ECDSA key fingerprint is SHA256:Nr3mtGvtxhNNMeCzpy642VkASYji/u0xESuTTVKe4.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/stanley/.ssh/known_hosts).
        ******** WARNING: UNAUTHORIZED PERSONS, DO NOT PROCEED ********
This system is intended to be used solely by authorized users in the course of
legitimate corporate business.  Users are monitored to the extent necessary to
properly administer the system, to identify the unauthorized users or users
operating beyone their proper authroity, and to investigate improper access or
use.  By accessing the system, you are consenting to this monitoring.
Additionally, users accessing this system agree that they understand and will
comply with all Verizon Information  Security and Privacy policies, including
policy statements, instructions, standards and guidelines.
        ******** WARNING: UNAUTHORIZED PERSONS, DO NOT PROCEED ********

Load key "/home/stanley/.ssh/stanley_rsa": Permission denied
[email protected]'s password:
@arm4b arm4b added the bug Something isn't working label Sep 10, 2019
@arm4b
Copy link
Member

arm4b commented Sep 10, 2019

@arm4b arm4b added this to the prod/GA milestone Sep 10, 2019
@arm4b arm4b added this to TODO in ST2 HA in K8s via automation Sep 10, 2019
@cmmdrdata
Copy link
Author

Oh cool I'd love to. I'm not sure what the exact change is though . Is there an owner: attribute that I can add stanley to or is there some code that also has to read that attribute from the deployment.yaml template file ?

@arm4b
Copy link
Member

arm4b commented Sep 11, 2019

@cmmdrdata There is no owner attr for K8s volumes, but changing mode to allow reads from others, eg 0444 permission would be sufficient.

@cmmdrdata
Copy link
Author

got it, some ssh servers won't let you login though if your key is too open for reading right ?

@arm4b
Copy link
Member

arm4b commented Sep 11, 2019

That's a good point, I forgot that.

Another thing I just searched for is trying to rely on securityContext.fsGroup to utilize stanley as a group owner. Not sure if that'll work, needs verifying.

@arm4b
Copy link
Member

arm4b commented Sep 12, 2019

BTW, after looking at the working stackstorm-ha cluster, st2actionrunner as used by StackStorm has no problems in picking up stanley SSH key as the service is running under root and has different SSH client primitives under the hood.

As a workaround, using ssh undercloud.admin -i /home/stanley/.ssh/stanley_rsa as root should work for you in a meantime.
The right way ideal solution: we indeed should make sure stanley group can read the SSH key.

@cmmdrdata
Copy link
Author

security context changed the group ownership on the volume but nt the file :( inside st2actionrunner pod.

ls -l /home/stanley/.ssh/
total 0
lrwxrwxrwx 1 root root 18 Sep 14 16:52 stanley_rsa -> ..data/stanley_rsa

root@stackstorm-st2actionrunner-7888d8ffc7-ml99n:/opt/stackstorm# ls -ld /home/stanley/.ssh/
drwxrwsrwt 3 root stanley 100 Sep 14 16:52 /home/stanley/.ssh/

@arm4b
Copy link
Member

arm4b commented Sep 17, 2019

Ah, that's really a bummer.

I found this discussion which still seems to be still an issue in K8s: kubernetes/kubernetes#81089

The workaround is pretty hacky: https://stackoverflow.com/questions/49945437/changing-default-file-owner-and-group-owner-of-kubernetes-secrets-files-mounted, - copy a secret to a normal file via intermediate InitContainer, then change its ownership.

@cognifloyd
Copy link
Member

cognifloyd commented Jun 22, 2021

@cognifloyd
Copy link
Member

#206 fixes this issue. Additional eyes on the fix would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
ST2 HA in K8s
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants