Author Topic: Ugh, help with SCP  (Read 3353 times)

0 Members and 1 Guest are viewing this topic.

Offline Joe

  • B&
  • x86
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Ugh, help with SCP
« on: April 13, 2006, 06:35:31 pm »
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? =)
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Ugh, help with SCP
« Reply #1 on: April 13, 2006, 07:06:56 pm »
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 /

Offline Joe

  • B&
  • x86
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: Ugh, help with SCP
« Reply #2 on: April 13, 2006, 08:28:01 pm »
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?
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline Ergot

  • 吴立峰 ^_^ !
  • x86
  • Hero Member
  • *****
  • Posts: 3724
  • I steal bandwidth. p_o
    • View Profile
Re: Ugh, help with SCP
« Reply #3 on: April 13, 2006, 08:47:59 pm »
It prompts for a password.

scp --help
man scp
Who gives a damn? I fuck sheep all the time.
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

Offline Joe

  • B&
  • x86
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: Ugh, help with SCP
« Reply #4 on: April 13, 2006, 09:07:53 pm »
Well then that's a bad thing. This is for a crontab file, I need to be able to run scp without being there. =/
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline Newby

  • Moderator
  • Hero Member
  • *****
  • Posts: 10877
  • Thrash!
    • View Profile
Re: Ugh, help with SCP
« Reply #5 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. :)
- 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

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. 

Offline Joe

  • B&
  • x86
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: Ugh, help with SCP
« Reply #6 on: April 14, 2006, 02:39:53 am »
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Ugh, help with SCP
« Reply #7 on: April 14, 2006, 12:52:30 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?

Offline Joe

  • B&
  • x86
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: Ugh, help with SCP
« Reply #8 on: April 14, 2006, 03:18:30 pm »
Yeah iago, that's exactly what I did, the whole key thing. It's what the link said to do, so eh.
I'd personally do as Joe suggests

You might be right about that, Joe.