I want to write a script so that when I save my .jsp file, it'll automatically upload itself to a server. I don't have a lot of control over the server, so using NFS isnt' really an option.
There is no ftpd on the server, just sshd. I know the windows version of ssh (from www.ssh.com) has a built-in file transfer thing, but is there some way to do that manually?
Try PSCP (http://the.earth.li/~sgtatham/putty/latest/x86/pscp.exe) from the maker of PuTTY (http://www.chiark.greenend.org.uk/~sgtatham/putty/).
edit:
Or, if you're doing this on some non-Windows OS, there probably is a native scp.
Oh yeah, forgot to mention, this is linux --> Solaris.
I'll take a look at that, anyway, it might give me some hint about what to look up. Thanks!
scp somefile.jsp
[email protected]:/some/absolute/path/here
scp somefile.jsp
[email protected]:path/relative/to/home/dir
beautiful, thanks!
Where did you find out about that?
scp (stands for Secure CoPy) is pretty well know, and it comes normally along with an sshd. he (Adron) most likely stumbled upon it when looking for a simplified way to transfer files without the use of a ftpd.
Not really. I stumbled on it as a companion to cp and rcp. It's often used to copy things between unix machines. If you use it with ssh and key forwarding / public key authentication, it works extremely well. Copying between computers is virtually as easy as copying inside a computer, no passwords or anything to worry about.
How do you do that key forwarding/public key whatever? I can just redirect stdin from a file containing the password, too, it's not exactly a secure system. It's an internet computer with no access to the internet, and everybody here knows the root password :)
<edit> also, I don't know anything about shell scripting. I want to back up the old file based on the date, how would I do that? I have this so far:
scp [email protected]:/public_html/$1 [email protected]:/public_html/bak/$1
scp $1 [email protected]:/public_html/$1
But I'd like to back it up so it looks like:
test.jsp-[date] or test.jsp-[time] or test.jsp-[rand] or anything. But I don't know how to concatinate strings within the commandline..
scp [email protected]:/public_html/$1 [email protected]:/public_html/bak/$1-`date +%Y%m%d%H%M%S`
For public key auth, use ssh-keygen on the computer you are running the commands on to generate a key. Then add the public part of that key (identity.pub) to ~/.ssh/authorized_keys on the machine you're ssh:ing/scp:ing to.
SFTP will probably work too