-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
SSH remote permission error #2535
Comments
Hi @ynop ! Please post full |
Yes creating manually works.
This error appears multiple times. |
@ynop Btw, could you try downgrading to 0.59.2 to see if that one is affected too? We did add a few changes to those lines in 0.60.0, so it might be the cause. |
I have tried 0.59.2, but ends up with the same errors. Here is the log (using 0.60.0). |
@ynop , are you using the same user in your test and with DVC? |
@ynop , I'll try to replicate it |
@ynop , I wasn't able to reproduce it: sudo systemctl start sshd
sudo mkdir -p /cluster/data/${USER}
sudo chown ${USER} -R /cluster/data/${USER}
ls -lah /cluster/data/
#
# Permissions Size User Group Date Modified Name
# drwxr-xr-x - mroutis root 25 Sep 19:54 mroutis
ssh localhost mkdir /cluster/data/${USER}/test
ls -lah /cluster/data/${USER}
#
# Permissions Size User Group Date Modified Name
# drwxr-xr-x - mroutis mroutis 25 Sep 20:05 test
dvc init --no-scm
dvc remote add ssh ssh://${USER}@localhost/cluster/data/${USER}
echo "foo" > foo
dvc add foo
dvc push -r ssh
ls -R -lah /cluster/data/mroutis
# Permissions Size User Group Date Modified Name
# drwxr-xr-x - mroutis mroutis 25 Sep 21:11 d3
# drwxr-xr-x - mroutis mroutis 25 Sep 20:05 test
#
# /cluster/data/mroutis/d3:
# Permissions Size User Group Date Modified Name
# .rw-r--r-- 4 mroutis mroutis 25 Sep 21:11 b07384d113edec49eaa6238ad5ff00
dvc version
#
# DVC version: 0.60.0
# Python version: 3.7.4
# Platform: Linux-5.3.1-arch1-1-ARCH-x86_64-with-arch
# Binary: False
# Cache: reflink - True, hardlink - True, symlink - True
# Filesystem type (cache directory): ('xfs', '/dev/mapper/vg-root')
# Filesystem type (workspace): ('xfs', '/dev/mapper/vg-root') Looking at your log, it looks like is trying to create
So, after 3
Can you make sure the |
@ynop , it is not from the root, it is from the first existing directory: dvc/dvc/remote/ssh/connection.py Lines 85 to 90 in be012e7
import posixpath
head, tail = posixpath.split('/cluster/data/user/5a/9ab1413269d550586b4586714e3ffc')
print(head) # '/cluster/data/user/5a'
print(tail) # '9ab1413269d550586b4586714e3ffc' |
If i a add log outputs like that: if stat.S_ISDIR(st_mode):
logger.debug('Directory')
return
else:
logger.debug('Not a directory') Then i get an output like that:
And the directory /cluster/data/user does exist. |
I logged the file mode that i get: logger.debug(stat.filemode(st_mode))
Seems that it can't retrieve the file mode for the mounted directories. |
@ynop Indeed, that is the cause. Very interesting. Does running |
|
@ynop The |
@ynop Btw, could you show full |
@ynop Btw, one more workaround that comes to mind is to create something like |
When I log The workaround is not really possible, since all places I have access to are on the mounted volumes. |
@ynop Btw, and what does |
Exactly the same output. |
@ynop Did I get you right, that you we're either using pdb or modifying dvc code in place and running it? If so, would you mind showing |
@ynop I've taken a look at paramiko's and openssh's stat function, and they both seem pretty normal and just passing st_mode intact from original stat() call on the server. I wonder if CLI utility |
On the server via python it seems to work just fine. >>> os.lstat('/cluster').st_mode
16877
>>> os.stat('/cluster').st_mode
16877
>>> stat.S_ISDIR(os.stat('/cluster').st_mode)
True
>>> stat.S_ISDIR(os.lstat('/cluster').st_mode)
True |
When printing with ignore_file_not_found():
logger.debug(self.sftp.stat(path).st_mode) |
@ynop maybe it is because it is raising an exception there. How about |
Then I get |
@ynop That is weird. I think there is a miscommunication here. Btw, how about we get a video call together, so I could take a closer look at it, so we don't spend so much time going back and forward in the comments for this issuse? 🙂 |
Unfortunately thats not possible today, as I am in a classroom. |
@ynop Sure, we can do it tomorrow or whenever you'll have time, if we don't figure this out remotely here. 🙂 Ok, so
you ran in makedirs when it failed, right? Or in some other way? Are you modifying dvc package in-place? Maybe consider adding |
I'm modifying the code in-place in the venv. |
But |
Ah sorry, overlooked that. |
@ynop |
Yeah, I also checked that by copying the url from the log and scp'd something there. |
Hmm just found a solution, although i don't know why it is like that. When I change the path in the dvc config, it works. |
@ynop Oh, that makes total sense! So your sftp server on that machine is configured with the root of |
@ynop I imagine you don't have access to /etc/ssh/sshd_config on the server, right? But even if you don't., this explains everything perfectly. |
Yeah, seems that way. Thanks for the help and sorry for the circumstances. |
@ynop Nothing to be sorry for. This was extremely useful and will help debugging similar issues in the future! 🙂 Thank you! |
@ynop So in the end, this was an sftp server configuration caveat, that dvc can't really do much to mitigate. But we can and should improve the error message to something like |
Not sure what you want to compare it with, |
@efiop , true, forgot that chrooting changes also the PWD and friends to reflect the new jailness. |
* sftp: add a more descriptive error on mkdirs Fix #2535 * sftp: raise exception instead of logging one
Hi
I get a permission error when trying to push to an ssh remote.
I assume it is due to the fact, that I don't have full permission on the remote (only from /cluster/data/user onwards)
As far as I can see dvc tries to create directories from the root.
dvc/dvc/remote/ssh/connection.py
Lines 96 to 110 in be012e7
Is this the intention or do i get something wrong?
I tried using password and keyfile.
Config:
['remote "cluster"']
url = ssh://user@host/cluster/data/user
user = user
keyfile = path-to-keyfile
Info:
dvc version 0.60.0
macos
pip installed
The text was updated successfully, but these errors were encountered: