I have a file with 700 permission in my local. I need to move this file to abc directory in a server using scp command. Here, file permission should be 755 but I am getting file with 700 permission only. How can I set permission to 755 for all file moving to this directory as default.
You could use rsync for the transfer:
rsync --chmod=u+rwx,g+rwx,o+rx file.txt user#host:abc/
If you prefer to use scp, you could set permissions after the transfer:
scp file.txt user#host:abc/
ssh user#host 'chmod 755 abc/file.txt'
Related
I don't want to use chmod 777 *.xml so how I can use MPUT to put the file with permission 777?
Now when I do not use chmod 777 *.xml then default put file with permission 0664.
This is my script
dir
lcd E:\Inbound
cd /interface/incoming
mput *.xml
chmod 777 *.xml
Thanks,
On Windows, psftp does not support setting permissions of files while uploading them. So setting the permissions after upload using chmod command is the only way.
On *nix, psftp preserves permissions of source files.
I'm trying to upload a file from my local desktop to a server and I'm using this command:
scp myFile.txt cooluser#192.168.10.102:/opt/nicescada/web
following the structure: scp filename user#ip:/remotePath.
But I get "Permission Denied". I tried using sudo , but I get the same message. I'm being able to download from the server to my local machine, so I assume I have all permissions needed.
What can be wrong in that line of code?
In case your /desired/path on your destination machine has write access only for root, and if you have an account on your destination machine with sudo privileges (super user privileges by prefixing a sudo to your command), you could also do it the following way:
Option 1 based on scp:
copy the file to a location on your destination machine where you have write access like /tmp:
scp file user#destinationMachine:/tmp
Login to your destination machine with:
ssh user#destinationMachine
Move the file to your /desired/path with:
sudo mv /tmp/file /desired/path
In case you have a passwordless sudo setup you could also combine step 2. and 3. to
ssh user#destination sudo mv /tmp/file /desired/path
Option 2 based on rsync
Another maybe even simpler option would be to use rsync:
rsync -e "ssh -tt" --rsync-path="sudo rsync" file user#destinationMachine:/desired/path
with -e "ssh -tt" added to run sudo without having a tty.
Try and specify the full destination path:
scp myFile.txt cooluser#192.168.10.102:/opt/nicescada/web/myFile.txt
Of course, double-check cooluser has the right to write (not just read) in that folder: 755, not 644 for the web parent folder.
I have to give access to some launcher inside "folder1".
Whenever a new folder is created inside "folder1", I have to again give the permissions by typing sudo chmod -R 0777 folder1. Is there a way that I could permanently enable 0777 for a particular folder. No matter how many new subfolders are created inside it.
I tried and it works. But I have to give the permissions again and again
sudo chmod -R 0777 folder1
You need to umask command in your ".profile" file in your home path. Then restart your session and create new folder. All the folders will get fill permission by default for all users.
Command $ umask 000
Open .profile file
Insert command "umask 000" in .profile file and save it.
Restart the session and create folders.
I will try setfacl to set ACLs, e.g.:
setfacl -m d:o::7,d:g::7,d:o::7 mydir/
setfacl -m o::7,g::7,o::7 mydir/
Actually, this way if you create directories under mydir they will have 0777 permissions and files will have 0666.
Hope it is useful
Cheers
I am moving a file newp from Directory Lenovo to Users it says permission denied in cygwin.
Lenovo#Aditya /cygdrive/c/Users/Lenovo
$ mv newp ../
mv: cannot move 'newp' to '../newp': Permission denied
How do I change the permission?
Steps to make this work:
1.)Generate the SSH keys from ssh-keygen.
2.)Enter to the remote server and in that create a folder named .ssh/authorized_keys.
3.)Copy paste the key in the remote server's authorized_key folder.
4.)Run command rsync -avz -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --progress hello.txt ec2-user#xx.xx.xxx.xx:/home/ec2-user
Note: hello.txt is a file that is created, which is to transfer to remote server.
Follow this link here to get the more idea.
I would like to upload my logo image to the website. To upload it to the Linux server from my computer, i created a directory "media" in the /var/www/html and tried this command:
scp /Users/kateryna/Desktop/my_site/pics/Logo.png root#95.142.160.135:/var/www/html/media
After this I entered the password to the server and then nothing happened, I got an error:
/Users/kateryna/Desktop/my_site/pics/Logo.png: No such file or
directory
.... even though the file exists on my machine.
Why does it happen? maybe I need to give some sort of permission? I read in one of the articles that to allow an upload, my folder permissions must be set to 777 with the command sudo chmod 777 /path/to/upload/folder... tried that for a different directory and didnt work either:
root#production-381d063e:~/new/myMedia# sudo chmod 777 /root/new/myMedia
-bash: sudo: command not found
root#production-381d063e:~/new/myMedia# chmod 777 /root/new/myMedia
root#production-381d063e:~/new/myMedia# scp /Users/kateryna/Desktop/my_site/pics/Logo.png root#95.142.160.135:/root/new/myMedia
root#95.142.160.135's password:
/Users/kateryna/Desktop/my_site/pics/Logo.png: No such file or directory
root#production-381d063e:~/new/myMedia#
Thanks so much!!!!!