Valhalla Legends Archive

General => General Discussion => Topic started by: iago on January 12, 2004, 03:41 PM

Title: Moving files around with only ssh
Post by: iago on January 12, 2004, 03:41 PM
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?
Title: Re:Moving files around with only ssh
Post by: Adron on January 12, 2004, 03:55 PM
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.
Title: Re:Moving files around with only ssh
Post by: iago on January 12, 2004, 04:21 PM
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!
Title: Re:Moving files around with only ssh
Post by: Adron on January 12, 2004, 04:40 PM
scp somefile.jsp [email protected]:/some/absolute/path/here

scp somefile.jsp [email protected]:path/relative/to/home/dir

Title: Re:Moving files around with only ssh
Post by: iago on January 12, 2004, 05:57 PM
beautiful, thanks!

Where did you find out about that?
Title: Re:Moving files around with only ssh
Post by: cipher on January 12, 2004, 11:28 PM
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.
Title: Re:Moving files around with only ssh
Post by: Adron on January 13, 2004, 04:49 AM
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.
Title: Re:Moving files around with only ssh
Post by: iago on January 13, 2004, 08:20 AM
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..
Title: Re:Moving files around with only ssh
Post by: Adron on January 13, 2004, 12:16 PM

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.
Title: Re:Moving files around with only ssh
Post by: wut on January 13, 2004, 01:52 PM
SFTP will probably work too