[Bugfix:System] Vagrant workers ssh fix#12798
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12798 +/- ##
=========================================
Coverage 21.67% 21.67%
Complexity 9807 9807
=========================================
Files 268 268
Lines 36722 36722
Branches 490 490
=========================================
Hits 7960 7960
Misses 28276 28276
Partials 486 486
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Rkoester47
left a comment
There was a problem hiding this comment.
I replicated the bug on main and then followed the steps on this branch. I can confirm that functionally, the changes described on this PR perform as described. I was able to go through all of the testing steps and encountered no errors while on this branch.
| w = subprocess.run(['su', DAEMON_USER, '-c', f"scp -i /tmp/worker_keys/{name} -o StrictHostKeyChecking=no ~/.ssh/id_rsa.pub root@{data['ip_addr']}:/tmp/workerkey"]) | ||
| w = subprocess.run(['su', DAEMON_USER, '-c', f"ssh -i /tmp/worker_keys/{name} -o StrictHostKeyChecking=no root@{data['ip_addr']} \"chown {SUPERVISOR_USER}:{SUPERVISOR_USER} /tmp/workerkey && su {SUPERVISOR_USER} -c \\\"mkdir -p ~/.ssh && mv /tmp/workerkey ~/.ssh/authorized_keys\\\"\""]) | ||
| if w.returncode == 0: | ||
| w = subprocess.call(['su', DAEMON_USER, '-c', f"scp -i /tmp/worker_keys/{name} -o StrictHostKeyChecking=no ~/.ssh/id_rsa.pub root@{data['ip_addr']}:/tmp/workerkey"]) |
There was a problem hiding this comment.
why did we switch to .call? .call is the legacy function. .run is the preferred method.
Other than this change, I can't tell if anything else was changed on these lines.
### Why is this Change Important & Necessary? #12798 was merged despite failing Python CI. ### What is the New Behavior? Fixes the Python CI.
solves #12796
Why is this Change Important & Necessary?
as linked in the attached issue, worker machines cannot be directly accessed from the main vagrant machine. This is obviously a problem considering this is the primary way vagrant workers are accessed. This PR makes vagrant workers accessible from the host vagrant machine.
The main problem present is that the authorized keys that are initialized when workers are being provisioned are for the root user. After this, the same configuration for authorization is overwritten by
install_system.sh. The currentrefresh_vagrant_workersfunctionality expects the root creds, but instead gets the vagrant creds, and fails.What is the New Behavior?
Now, when ssh worker-x (where x is whatever worker you're trying to connect to) is run on the submitty_daemon user, workers are connected and a ssh connection succeeds.
What steps should a reviewer take to reproduce or test the bug or new feature?
as linked in the issue, to test the problem:
pre-requirements: have a running submitty development machine on vagrant
vagrant workers generate, vagrant workers up)vagrant ssh)refresh_vagrant_workersin any directoryto test my solution, swap to the attached branch and repeat the steps above and observe that you can now connect to the aforementioned worker:
sudo su submitty_daemonssh worker-x, with x as whatever work you're attempting to access.Automated Testing & Documentation
Other information
This is not a breaking change. Securitywise, it shouldn't be a problem, but that doesn't mean it's not. Since we're dealing with ssh that can always open up potential vectors, but to my knowledge my changes shouldn't affect any security concerns.