LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   SSH File transfer (https://www.linuxquestions.org/questions/linux-general-1/ssh-file-transfer-411977/)

wjeanpaul 02-05-2006 03:50 PM

SSH File transfer
 
My webserver does not recognize my index.html (other files) file after transferring them using SSH. I first transfer the files to my home directory and move them my DirectoryRoot folder. Furthermore, when created the files using vi, they work.

Please help


**Using Fedora core 4

Thanks.


Additional info:It is not an ssh problem, It's not a web server problem, it is not a file permission problem, it is not a file ACL problem and it is not an EOL problem. It is a selinux problem.

***Looking in /var/log/audit/audit.log, I noticed the following message below when the web server attempted to load the index.html file:
----type=AVC msg=audit(1138942941.128:7132253): avc: denied { getattr } for pid=13582 comm="httpd" name=index.html dev=dm-0 ino=265 scontext=root:system_r:httpd_t tcontext=user_u:object_r:user_home_t tclass=file


According to my friend, I need to figure out how to do the following -- for SElinux:
1) how to configure the with right permissions for your files, or
2) shut it off (at least for now)


Issue resolved: restorecon -R 'WebDirectoryName' fixed my issue.

teckk 02-05-2006 03:54 PM

Are you sure that you are not using an editor that is putting a format on your index.html? You say that when you use VI all is well.

wjeanpaul 02-05-2006 03:57 PM

I used Dreamweaver to create and edit the files and then SSH them to my Server. Unfortunately, that method does not work. When I create the files using vi, it works.

Nathanael 02-05-2006 04:24 PM

did you check the file permissions and ownerships after ssh'ing them across to your server?

wjeanpaul 02-05-2006 04:31 PM

Yes, I checked the permissions.

[@new-host-2 html]$ ls -l
total 44
drwxr-xr-x 2 root root 4096 Feb 3 02:52 images
-rw-r--r-- 1 root root 3431 Feb 3 17:58 index.html
drwxr-xr-x 4 root root 4096 Feb 3 02:53 JPintel
-rw-r--r-- 1 root root 5382 Mar 7 2005 page.html
-rw-r--r-- 1 root root 4009 Mar 7 2005 style.css
[@new-host-2 html]$ cd images/

Nathanael 02-05-2006 04:45 PM

have you tried chmod +x *

wjeanpaul 02-05-2006 04:51 PM

yep. No luck.

michaelk 02-05-2006 05:00 PM

Are you creating the files on a windows PC? unix/linux uses different end of line characters then windows/DOS. There are lots of methods to convert DOS to unix format:
dos2unix utility
via vi
use command set ff=unix and save file.

via tr
tr -d '\15\32' < winfile.txt > unixfile.txt

via awk
awk '{ sub("\r$", ""); print }' winfile.txt > unixfile.txt

wjeanpaul 02-05-2006 05:28 PM

Yes, I am creating the files using Dreamweaver on XP.

michaelk 02-05-2006 09:44 PM

Then you need to convert the text files using one of the methods posted above.

wjeanpaul 02-05-2006 09:56 PM

SSH help
 
Thanks. They are not text files. They are html, ASP, PHP and images. Can I use the same method above? Also, can you please be specific with your method.

Thanks.

michaelk 02-05-2006 10:15 PM

html, php and asp are ASCII text files. BTW vi is a text editor. I assume by images you mean something like tiff or jpg which are binary files and they do not need to be converted. Windows/DOS end of line characters ore 0x0D, 0x0D, and unix/linux only uses 0x0A. So files generated on windows must have the 0x0D character removed.

tr and awk are command line utilities that can manipulate text.
In a console window you would type the command as shown subsituting winfile.txt for the original file transfered and unixfile.txt would be the new file name where the converted text is saved.

With vi you open the file, enter the set ff command and then save the file. Check the bottom of the monitor you should see DOS on the status line when the file is first opened.

The dos2unix is a utility that will convert files too
usage:
dos2unix winfile.txt unixfile.txt

michaelk 02-05-2006 10:56 PM

Let me explain...
Text files are based on ASCII which is a code for representing English characters as numbers, with each letter assigned a number from 0 to 127. Most computers use ASCII codes to represent text, which makes it possible to transfer data from one computer to another. txt, html, php, asp, csv, sh, conf are common extensions but they are all text files.

spooon 02-05-2006 11:14 PM

Quote:

Originally Posted by wjeanpaul
My webserver does not recognize my index.html (other files) file after transferring them using SSH. I first transfer the files to my home directory and move them my DirectoryRoot folder. Furthermore, when created the files using vi, they work.

Please help


**Using Fedora core 4

Thanks.

They may have the wrong SELinux context; do "restorecon" on the files and see if that helps.

Nathanael 02-06-2006 05:09 AM

i have run many files created on windows, and served by a linux apache2 server. i have never had the need to change then EOL in the files.


All times are GMT -5. The time now is 10:06 PM.