Permission denied with .put()
ElieTaillard opened this issue · comments
I'm getting an exception with the function .put()
scp.put(files=localPath,remote_path=remotePath,recursive=True)
localPath
='C:\\Users\\taill\\AppData\\Local\\Temp\\tmpycfisven\\Version1.1\\builtapp'
remotePath
='/var/www/projet41_new'
I checked to see if I had the writing rights and I do. I can transfer files with WinSCP but with the put() function it doesn't work.
I also tried to do a file transfer from a linux machine to my target machine (linux), with the scp command. And it works.
I tried to run the script from a linux machine and I get the same error.
As you can see I'm trying to scp from a temporary folder, I tried with a normal folder and it doesn't work
I checked and the temporary folder does exist.
Does anyone have a solution to the problem?
This is the part of my script where I'm using scp :
p = paramiko.SSHClient()
p.load_system_host_keys()
p.set_missing_host_key_policy(paramiko.AutoAddPolicy())
print("Entrez le mot de passe pour l'utilisateur '" + VMWEB1_PROD_USERNAME + "'")
passwordVm = input()
p.connect(VMWEB1_PROD_IP, username=VMWEB1_PROD_USERNAME, password=passwordVm)
scp = SCPClient(ssh.get_transport())
remotePath = os.path.join(VMWEB1_PROD_DIRECTORY,VMWEB1_PROD_PROJECT_NAME + "_new")
localPath = os.path.join(temp_dir_output.name,versionName,BUILT_APP_FOLDER_NAME)
print("Upload du dossier built vers la VM WEB 1")
scp.put(files=localPath,remote_path=remotePath,recursive=True)
Can you post the full error please?
On my windows pc :
Traceback (most recent call last):
File "AutoDeploy.py", line 92, in <module>
scp.put(files=localPath,remote_path=remotePath,recursive=True)
File "C:\Users\taill\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\scp.py", line 199, in put
self._send_recursive(files)
File "C:\Users\taill\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\scp.py", line 367, in _send_recursive
self._chdir(last_dir, asbytes(root))
File "C:\Users\taill\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\scp.py", line 355, in _chdir
self._send_pushd(to_dir)
File "C:\Users\taill\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\scp.py", line 381, in _send_pushd
self._recv_confirm()
File "C:\Users\taill\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\scp.py", line 404, in _recv_confirm
raise SCPException(asunicode(msg[1:]))
scp.SCPException: scp: /var/www/projet41_new: Permission denied
I feel like I've tried everything...
I will try to do with os.system('scp') for now.
We'll see if it works.
Looks like you don't have permission to go into that folder. I don't think there is a bug in scp.py.
I do have write permissions on /var/www
Should the remote path point to an existing folder, or will the function create the folder I specify (project41_new) ?
What is the exact mode of the folder?
I tried chmod 777 on /var/www and it still doesn't work.
It's weird because with the scp command it works
Does the mode on /
, /var
, or /var/www
not include the r
or x
bit?
SCP works with the instruction : os.system("scp -r " + localPath + " " + VMWEB1_PROD_USERNAME + "@" + VMWEB1_PROD_IP + ":" + remotePath)