[Core] Set file permission when writing the ssh config file #3151
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We now explicitly set the permission for the ssh config file writen by SkyPilot, because sometimes if the user changed the username of their local machine, and still use the conda environment with skypilot installed under the old
/home/old-user
folder. In this case, the files writen to~/.sky/generated/ssh
can have a permssiondwxr-rw-rw--
which violates the permission required for ssh, causing allssh
fails.This is one of the potential reasons for #2689. This PR also prints out the output of the last ssh command if the wait ssh timeout.
Reproducible steps:
docker run -it --rm centos:centos7 /bin/bash
adduser -m test-original; adduser -m test-new
passwd test-original; passwd test-new
sermod -aG wheel test-new; sermod -aG wheel test-original
su test-original; # setup miniconda
setfacl -R -m u:test-new:rwx /home/test-original/
su test-new; /home/test-original/miniconda3/bin/conda init; # install skypilot
sky launch --cloud gcp --cpus 2 echo hi; # task submission fails due to ssh permission issue with the folder
By deleting
~/.sky/generated/ssh
and switch to this PR, the problem goes away.Tested (run the relevant ones):
bash format.sh
pytest tests/test_smoke.py
pytest tests/test_smoke.py::test_fill_in_the_name
bash tests/backward_comaptibility_tests.sh