sending files to virtual machine SCP - linux

I am trying to transfer files over to my virtual machine
I tried the command
scp files user#xxx.xx.xx.xxx:/home/user/directory
I am later asked to enter the password for user#xxx.xx.xx.xxx
When I enter the password the output is:
scp: /home/user/directory/filename: Permission denied
I thought perhaps I don't have the correct permissions or rights to the files?
So I checked rights for each file and it is
-rwxr-xr-x
Not really sure what I need to do to correctly SCP my files over to my virtual machine

Make sure that user exists on both machines and that it has permission to write to the destination directory. This means the destination directory must either be a) world-writable, b) writable by a group that user belongs to, or c) owned by user.

Related

Changing default files permission in Linux

I work under Centos 7.
For some time, I have a problem with the FTP /home/students directory whose access rights( permission) is set to 750. When I create a file as user students the file access permission is 644 (read/write for the owner and read-only for other users). But when the students user receives files by SFTP (with authentication by ssh key), the permission of these files is 600.
Can the right of access (permission) be imposed by the one who uploads the file by SFTP?
How to make the default permission for files received by SFTP automatically 644?
Thank you
I think u should do something like this > Modify /etc/ssh/sshd_config :
Subsystem sftp internal-sftp -m 0644
Then u should reload the SSHD Configuration :
sudo systemctl reload sshd

How to delete target folder created using scp by target user

I have a machines A B C. only Machine B have access to A & C. For machine A I have root access , machine B I have root access and for machine C I have User level access.
1.2.3.4 is the ip address assigned to machine B.
When I am doing from machine A as
scp -pr ./logs/ root#1.2.3.4:/common/tftpboot/
It creating folder name logs inside <machine C>:/common/tftpboot/
I have given all read write execute permission to all user groups and others as machine A is comes under others using chmod 777 tftpboot
Now after copying logs folder I am not able to delete the <machine C>:/common/tftpboot/logs/folder from User of machine C though machine C user has given the 777 permission to /common/tftpboot/ folder as the logs folder is created by others i.e machine A root
So I want to do scp to copy the folder only (and not individual files) and still I want that user c should able to delete the folder created by machine A scp after analysing logs
Now I need to do ssh to Machine B from Machine A and then only I can able to delete the scp created logs folder.
can anybody help to do so ??
before doing SCP I have changed permission of the logs folder to 777 i.e chmod -R 777 ./logs and now I can able to delete the folder created by scp at Machine C

SSH Change ownership of public_html

The default ownership for public_html was myusername:nobody
drwxr-xr--. 18 myusername nobody 4096 Jun 1 16:06 public_html/
I changed this to myusername:myusername since I need to access a file inside public_html using the following command
# chown myusername:myusername public_html
It worked and ownership changed.
Now I'm not able to change the ownership back to myusername:nobody. I'm using this command
chown livegiftcard:nobody public_html
and it gives me the error
chown: changing ownership of âpublic_htmlâ: Operation not permitted
I have also tested this with sudo and also chgrp but no luck.
Also I could not run my website. Browser gives me the following error.
Forbidden
You don't have permission to access / on this server. Server unable to
read htaccess file, denying access to be safe
Additionally, a 403 Forbidden error was encountered while trying to
use an ErrorDocument to handle the request
Problem:
The apache/nginx has a user, who needs to read the files in the Docroot. Default user and group is: www-data:www-data. I'm not user if this is correct in your case.
Now the files are owned by myusername:myusername and the apache/nginx user is probably not in the the group "myusername". So if you have some knowledge about the permission system of linux, the webserver user have only the rights everybody have (third column). When the group was set to nobody, the files weren't owned by any group and every user can act under the group permissions. In your case I guess the group can read all files and all other can't.
What you can do:
Give all others the right to read the files with
chmod -R o+r public_html
Now everybody, including the webserver user can read the files and you will not get the 403 error. -R is for recursive, so every file and directory under public_html will get the readable flag too.
Another thing is to add the webserver user to the group "myusername" so the webserveruser can use the group permissions too.
The third and last possibility which came to my mind is to change the group to "nogroup" instead of "nobody" because nobody is the user and nogroup the group.

mySQLdump from Linux machine to a mounted Windows folder on a remote server

I am trying to do a mysqldump from a local Linux machine to a Windows folder that has been mounted on the system. This is the command I am using in the terminal:
mysqldump -u root -plinuxsux myDB -t LOG > /mounted folder/path/blah/myDB.sql
I am getting the following error:
/mounted folder/path/blah/myDB.sql: Permission denied
I checked the permissions of the folder on the Windows side, and there is a specific user that I created called Sys003 that has full control of that folder.
Do I need to put that user name (and password) into the command above to get it to work? And if so, how do I do that? Thanks.
The problem is that the user that is actually running the mysqldump command has not the permission to write on the destination folder.
One solution might be changing to the Sys003 user and run the mysqldump again:
normal_prompt> su Sys003
password...
Sys003_prompt> mysqldump...
Another one can be running mysqldump as your normal user, then copy the dump as Sys003:
normal_prompt> mysqldump... > /local/dump.sql
normal_prompt> su Sys003
password...
Sys003_prompt> cp /local/dump.sql /mounted_folder/path/blah/myDB.sql
Be careful, since your Sys003 user might not be authorized on running mysqldump, but that's a totally different question :)
It was an error in the /etc/fstab file. I had the user as a different user than Sys003. Once I put the user as Sys003 with their password, it worked.

problem with ftp pushing files and me not having access as regular user

I've run visudo and added my username to the list to be able to do whatever I need to rather than logging in as root user.
I have my svn push out file's through ftp as user www-data, and therefore when I try to cd into those directories, I get permission denied.
Any thoughts? Can I add my username to some config file somewhere to have access to all files?
When you use sudo, you are running as the root user, but only for that particular command. I think the easiest thing to do would be to ensure that you and www-data are in the same group, and set the group permissions accordingly. (e.g., chmod 775 yourdir)

Resources