sftp locally

2008-11-26T12:10:39Z
Dave Pawson.  link
Home

sftp locally

The problem. I have two local Linux boxes, both running Apache. I want to write some html and php to run on 'the other' one. That divides into two problems.

One. Telling Apache I don't want to have to edit files in /var/www/html. Solution one. Edit /etc/httpd/conf/httpd.conf to change


# This should be changed to whatever you set DocumentRoot to.
#    DocumentRoot /www/docs/dummy-host.example.com
DocumentRoot /files/php

Which lets me use files I can edit and serve them from Apache. Except.. That raises problem 1b

Apache doesn't like pulling files from there. Why? Because Apache doesn't own those files. So I create a group (choose a name), then add apache and me to that group.

$groupadd apchegrp
$useradd -G apchegrp apache
$useradd -G apchegrp dave

Problem solved.

Next, ftp. I need to get those html and php files from this machine a couple of feet over to the server next to me. I've used the ant ftp task in the past, but problems with access kicked me out (Fedora Core 9). So I started reading about sftp.... which took me to ssh... which led me to ... the answer. This was my source. Seems I need a public/private key pair. I'm a little confused as to where the key is needed (the server or the client), but $ ssh-keygen -t dsa was the magic incantation that worked. This is followed by scp ~/.ssh/id_dsa.pub dave@homer:.ssh/authorized_keys which is a copy over to the keychain on the remote machine (server in my case). Thereafter I can get a terminal into my server using ssh without a password... (or at least using a different method of access). A side effect is that sftp (which rides on the back of ssh) can now talk and send stuff over the link. So now I have a script,

# start up sftp, using a script file upload.scr
$sftp  -b upload.scr homer

# ... and the script file upload.scr reads

cd /shared/cakes
put *.php
put *.html
cd css
put css/*
cd ../cimg
put cimg/*
exit

Which are a bunch of non interactive sftp commands! Problem(s) solved.

Bit like Autocad. You know the tools are there to do it. Just a case of figuring out which tools to call on (and in this case which tools they call on). Reminds me of that saying about little fleas have smaller fleas, upon their backs to bite 'em!

I'm sure you knew this... but it's here to remind me now. OK!

Keywords: fedora

Comments (View)

Return to main index