• Welcome to Valhalla Legends Archive.
 

Moving files around with only ssh

Started by iago, January 12, 2004, 03:41 PM

Previous topic - Next topic

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?
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Adron

#1
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.

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!
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Adron

scp somefile.jsp [email protected]:/some/absolute/path/here

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


iago

beautiful, thanks!

Where did you find out about that?
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


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.

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.

iago

#7
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..
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Adron


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.

wut