I am running Ubuntu 9.10 desktop on my home machine. I need to upload files from my local machine, to my web server, on a periodic basis. My server is running Ubuntu Server LTS.
I want my server to be secure, and only run the LAMP stack and possibly, an email server. I do not (ideally) want to have FTP or anything that can allow (more) knowledgeable hackers to be able to hack into my server.
Can anyone recommend how I may send files from my local machine to the server?
This may seem an easy/trivial question, but I am relatively new to Linux - and I got my previous Windows server machine serious hacked in the past, hence the move to Linux, and thats why I am so security conscious.
[Edit]
There seems to be quite a lot of ways of doing this (judging from the answers I have received so far) - yet there seems to be no clear winner. therefore, I am adding some more information, in the hope that a clear winner (in terms of best practices) will emerge.
I would like to automate this - i.e. run from a shell script as a cron job.
I am concerned about security, and so, I dont want to have passwords in plain text in the scripts or to send passwords unencrypted etc
Both the client and (remote) server are Debian based, so hopefully, file permissions will be preserved in the copy.
i. If this is not possible, who will be the default owner of the copied files? The uploaded files will be read by another script (on the server). What should the relationship (in terms of file permissions) be, between the uploading script and the processing script?
chances are you already connect to the server using ssh.. so use scp or sftp which uses ssh as the protocol
It will prompt you for your password
If you want it to get easier and more secure.. look into logging in with ssh keys
EDIT
Here is the sftp.. works just like normal ftp once you are in
I would use scp if you want to automate it.. so to create a sshkey
If you want to automate it.. I recommend using no passpharse
Now you want to copy the key
Then you can ssh in with no password as that user while using that key. you can also use the same scp account with no password.. but it will only work with that key for the user you created it with.
Other, very convenient IMO, way is to mount your remote dir as local using
sshfs
and copy files as any other.rsync is a handy way to transfer files between servers. Works over SSH out of the box (and supports key-based passwordless SSH connections).
You can copy from local to remote or fetch from remote to local, etc. For example:
On the remote server it's good to use a non-root account, and set up an authorized_keys entry so that you don't need to put in your password. SSHing directly into root on another server is not a good idea - if you need root privs on the remote server, do the rsync from that end instead. If you think you need root privs on both servers, you may not: look into rsync's
--fake-super
option.I've looked at a number of HOWTOs online and a lot of them recommend frankly bad practices or are out of date (recommending authorized_keys2, rsa, etc). This one I recommend, it's good security-wise: http://troy.jdmz.net/rsync/index.html
If you need a GUI rather than command line option, just use SFTP. FileZilla is a dead easy client to use and drag'n'drop, and of course SFTP does everything over an SSH connection.
Again, connect to a non-root account on the remote server - and you can set up passwordless login by adding an authorized_keys entry to the remote machine. You'll need Pageant (comes with PuTTY) to manage keys on Windows.