News:

Happy New Year! Yes, the current one, not a previous one; this is a new post, we swear!

Main Menu

Ugh, help with SCP

Started by Joe, April 13, 2006, 06:35:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Joe

Ok, I have no clue how to do this. I want to copy a zip file from ~/Desktop/JBot/src.zip to joe@darkside:~/public_html/JBot/src.zip nightly, but I have no clue how to do this.

Also, I have to go through Pie to get to darkside, because apparently iago's port forwarding died (again).

Could one of you magicians spoon-feed the command do to this? =)
Quote from: Camel on June 09, 2009, 04:12:23 PMI'd personally do as Joe suggests

Quote from: AntiVirus on October 19, 2010, 02:36:52 PM
You might be right about that, Joe.


iago

There should be nothing wrong with the port forwarding.  The computer hasn't restarted and I haven't touched that service, so if it's not working then ssh would have had to crash or something. 

Anyway, scp is very simple.  It is in the form of:

scp <src> <dest>

Where src and dest are file paths.  A file path can be one of two things:
a) A direct or relative path to the file, like "/etc/passwd" or "./file.txt"
b) Made up of two parts, separated by a colon, "server:path".  In that case, the server is the server that is running ssh and path is the path of the file.

Note that b) can be used for the source or destination or both.  You can also put nothing for the path, just "server:" which copies it to the default folder. 

This would copy /etc/passwd on 192.168.1.2 to the root folder on 192.168.1.3:
scp 192.168.1.2:/etc/passwd 192.168.1.3:/

This would copy /etc/passwd on the current system to 192.168.1.3:
scp /etc/passwd 192.168.1.3:/

This would copy /etc/passwd on 192.168.1.2 to the root folder on the current computer:
scp 192.168.1.2:/etc/passwd /

Joe

scp ~/Desktop/JBot/src.zip www.javaop.com:~/public_html/JBot/src.zip

How do I send my password to darkside, and how do I use a port?
Quote from: Camel on June 09, 2009, 04:12:23 PMI'd personally do as Joe suggests

Quote from: AntiVirus on October 19, 2010, 02:36:52 PM
You might be right about that, Joe.


Ergot

It prompts for a password.

scp --help
man scp
Quote from: Newby on February 26, 2006, 12:16:58 AM
Who gives a damn? I fuck sheep all the time.
Quote from: rabbit on December 11, 2005, 01:05:35 PM
And yes, male both ends.  There are a couple lesbians that need a two-ended dildo...My router just refuses to wear a strap-on.
(05:55:03) JoE ThE oDD: omfg good job i got a boner thinkin bout them chinese bitches
(17:54:15) Sidoh: I love cosmetology

Joe

Well then that's a bad thing. This is for a crontab file, I need to be able to run scp without being there. =/
Quote from: Camel on June 09, 2009, 04:12:23 PMI'd personally do as Joe suggests

Quote from: AntiVirus on October 19, 2010, 02:36:52 PM
You might be right about that, Joe.


Newby

Joe: RTFM

Quote from: man scp (on FreeBSD 6.0)SCP(1)                  FreeBSD General Commands Manual                 SCP(1)

NAME
     scp -- secure copy (remote file copy program)

SYNOPSIS
     scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
         [-l limit] [-o ssh_option] [-P port] [-S program]
         [[user@]host1:]file1 [...] [[user@]host2:]file2

...

     -B      Selects batch mode (prevents asking for passwords or
             passphrases).

Read the red.

According to that, you should be able to supply the password (in the form of a text file or a parameter) if you use -B. Figure it out!

I wish I did man scp earlier. Sending all that Grave Digger to iago would have been quicker with -C and -l 30. :)
- Newby
http://www.x86labs.org

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote from: Rule on June 30, 2008, 01:13:20 PM
Quote from: CrAz3D on June 30, 2008, 10:38:22 AM
I'd bet that you're currently bloated like a water ballon on a hot summer's day.

That analogy doesn't even make sense.  Why would a water balloon be especially bloated on a hot summer's day? For your sake, I hope there wasn't too much logic testing on your LSAT. 

Joe

Quote from: Camel on June 09, 2009, 04:12:23 PMI'd personally do as Joe suggests

Quote from: AntiVirus on October 19, 2010, 02:36:52 PM
You might be right about that, Joe.


iago

Quote from: Newby on April 13, 2006, 11:30:36 PM
Joe: RTFM

Quote from: man scp (on FreeBSD 6.0)SCP(1)                  FreeBSD General Commands Manual                 SCP(1)

NAME
     scp -- secure copy (remote file copy program)

SYNOPSIS
     scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
         [-l limit] [-o ssh_option] [-P port] [-S program]
         [[user@]host1:]file1 [...] [[user@]host2:]file2

...

     -B      Selects batch mode (prevents asking for passwords or
             passphrases).

Read the red.

According to that, you should be able to supply the password (in the form of a text file or a parameter) if you use -B. Figure it out!

I wish I did man scp earlier. Sending all that Grave Digger to iago would have been quicker with -C and -l 30. :)

Nah, I've sent .mp3 files with -C before.  It sends slower because it takes more processing time but doesn't shrink it very much. 

And you should NOT supply the password in the plaintext file.  You should set up ssh with public/private keys. 

- On your computer, run "ssh-keygen -t rsa".  Go through the steps, and give it a blank password. 
- Open ~/.ssh/whatever.pub.  That's your public key
- Copy your entire public key
- Create a new file on the server, ~/.ssh/authorized_keys
- Put your public key in authorized_keys

Here's a simple way:
Quote
ron@slayer:~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ron/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ron/.ssh/id_rsa.
Your public key has been saved in /home/ron/.ssh/id_rsa.pub.
The key fingerprint is:
2b:f3:68:0b:79:81:f1:9d:be:c9:31:b5:d8:1c:42:b3 ron@slayer
ron@slayer:~$ scp .ssh/id_rsa.pub iago@darkside:.ssh/authorized_keys
iago@darkside's password:
id_rsa.pub                                    100%  220     0.2KB/s   00:00   
ron@slayer:~$ ssh iago@darkside
iago@darkside:~$



Notice how I didn't need a password the second time?  I cheated, though, by just renaming "id_rsa.pub" to authorized_keys.  If I ever wanted to add another key, I'd have to add the public key manually. 

Get it?

Joe

Yeah iago, that's exactly what I did, the whole key thing. It's what the link said to do, so eh.
Quote from: Camel on June 09, 2009, 04:12:23 PMI'd personally do as Joe suggests

Quote from: AntiVirus on October 19, 2010, 02:36:52 PM
You might be right about that, Joe.