Solved

Copy file (cp) from one command line (BSD) to another.

Posted on 2010-09-12
6
431 Views
Last Modified: 2012-06-27
logged in via ssh, need to copy a file from another machine back to my machine.
What is the command for the extraction of the file.
I know how to cp a file from directory to directory or mv, can't remember the command.
Unix.
0
Comment
Question by:T_Myles
6 Comments
 
LVL 6

Expert Comment

by:sagiamar
ID: 33658127
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 33658157
scp /source/file user@targethost:/target/directory/
or
scp user@sourcehost:/source/file /target/directory/
0
 

Author Comment

by:T_Myles
ID: 33658545
woolmilkporc:

I'm in the machine via ssh I want to send file to another remote server.
A directory is what I want to cp over.

Since I'm inside the machine, shouldn't there be a -R included, I'm confused about the second line.
If I can rap my head around the path I can get it.  
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Expert Comment

by:anoym
ID: 33658625
To copy files and subdirectories I'm using:

# scp -r -p /source_directory/* username@ip_adresse:/target_directory

To copy a whole directory you can use:

# scp -r -p /source_directory username@ip_adresse:/target_directory

and pls check:

http://amath.colorado.edu/computing/software/man/scp.html

0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 33660113
My first line is for copying a file /source/file from the machine you're logged in to a remote server named targethost as user user into the directory /target/directory there.
My second line is for copying a file /source/file from a remote server named sourcehost as user user into the local directory /target/directory
By the way, with scp you can even copy a file/files from one remote machine to another remote machine while being logged in via ssh to a third, arbitrary machine, and moreover, you can give it a new name (the italic string in angle brackets (  <... > ) is meant to indicate the shell prompt!)
<user0@somehost0> ssh user1@somehost1  # (or via PuTTY, or whatever)
<user1@somehost1> (Logged in)
<user1@somehost1> scp user2@somehost2:/source/file user3@somehost3:/target/directory/new_filename
<user1@somehost1> exit
<user0@somehost0>
 
All of the above is for files, since in your question you asked for copying a file.
There is no "-R" (uppercase R) for scp. To have scp work recursively use the "-r" (lowercase r) flag, as indicated by anonym.
wmp
0
 

Author Closing Comment

by:T_Myles
ID: 33662943
Thanks for the detail explanation.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know how boring and exhausting it is to transfer huge web projects developed locally to a webserver simply via FTP. The File Transfer Protocol is a really nice solution if you need to transfer small amounts of files, but if you're plannin…
When it comes to security, there are always trade-offs between security and convenience/ease of administration. This article examines some of the main pros and cons of using key authentication vs password authentication for hosting an SFTP server.
Viewers will learn how to properly install and use Secure Shell (SSH) to work on projects or homework remotely. Download Secure Shell: Follow basic installation instructions: Open Secure Shell and use "Quick Connect" to enter credentials includi…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now