Valhalla Legends Forums Archive | General Discussion | Moving files around with only ssh

AuthorMessageTime
iago
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?
January 12, 2004, 9:41 PM
Adron
Try PSCP from the maker of PuTTY.

edit:

Or, if you're doing this on some non-Windows OS, there probably is a native scp.
January 12, 2004, 9:55 PM
iago
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!
January 12, 2004, 10:21 PM
Adron
scp somefile.jsp iago@solarismachine.somewhere.edu:/some/absolute/path/here

scp somefile.jsp iago@solarismachine.somewhere.edu:path/relative/to/home/dir

January 12, 2004, 10:40 PM
iago
beautiful, thanks!

Where did you find out about that?
January 12, 2004, 11:57 PM
cipher
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.
January 13, 2004, 5:28 AM
Adron
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.
January 13, 2004, 10:49 AM
iago
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:
[code]scp root@207.161.144.66:/public_html/$1 root@207.161.144.66:/public_html/bak/$1
scp $1 root@207.161.144.66:/public_html/$1[/code]

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..
January 13, 2004, 2:20 PM
Adron
[code]
scp root@207.161.144.66:/public_html/$1 root@207.161.144.66:/public_html/bak/$1-`date +%Y%m%d%H%M%S`
[/code]

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.
January 13, 2004, 6:16 PM
wut
SFTP will probably work too
January 13, 2004, 7:52 PM

Search