LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 11-17-2004, 12:10 PM   #1
b123coder
Member
 
Registered: Nov 2004
Location: india
Distribution: Fedora core 1
Posts: 67

Rep: Reputation: 15
how can i secure file copy from pc to pc


Is it possible to use ftp to transfer a file from pc1 to pc2 with fix source location on pc1 and fix loaction on pc2 where it is to be copied/overwritten using any shell script or C program?
can scp is used for same purpose? how can i use that command in C program?
one more thing how a socket program can help in my condition?
 
Old 11-18-2004, 03:48 AM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990

Rep: Reputation: 66
Yes (assuming there's a suitable network, and network services, between the two).
Yes. Like this:
Code:
 system("scp user1@pc1:/path1/to1/file user2@pc2:/path2/to2/file");
You could use a socket program to send the file. Don't do that, as there are dozens of standards you could use, and you're more likely to make it less secure by using a custom program (fewer users => more bugs; security through obscurity doesn't work).

Last edited by rjlee; 11-18-2004 at 03:49 AM.
 
Old 11-18-2004, 08:28 AM   #3
meblost
Member
 
Registered: May 2004
Location: At Keyboard
Distribution: Mandrake 10.0, SuSE 9.0
Posts: 114

Rep: Reputation: 15
Code:
system("scp user1@pc1:/path1/to1/file user2@pc2:/path2/to2/file");
How is authentication handled in this situation?
 
Old 11-18-2004, 11:59 PM   #4
globeTrotter
Member
 
Registered: Feb 2004
Location: Townsville, Queensland, Oz
Distribution: Red Hat 9
Posts: 107

Rep: Reputation: 15
hi

scp authenticates by asking for the user2 password when you press enter to execute the command

to send a file from here to there, if here is pc1 & there is pc2

scp /path/to/file user@pc2:destination/path <enter>

you will be promted for user@pc2 password.

to get a file from there to here

scp user@pc2:source/path destination/path <enter>

so

scp silly.txt john@dadspc:.

will copy silly.txt from the pwd of the local pc and copy it in the home directory of john on the pc who's hostname is dadspc. dadspc can be replaced with the ip address. 192.168.1.3 etc.

scp john@dadspc:silly.txt .

will copy silly.txt from the home directory of john on dadspc and place it in the pwd directory of the local user. notice the period (.) this represents here (pwd) as in the folder/directory you are in when you issue the command.

all files are encrypted. sshd must be running on the remote machine for this to work.

hope this helps
regards
GT
 
Old 11-19-2004, 03:47 AM   #5
cranium2004
Member
 
Registered: Feb 2004
Distribution: FC4,RHEL4
Posts: 223

Rep: Reputation: 30
Hi globeTrotter,
i did as you said but i am getting followinf error in both cases you given after entering password for there pc
scp: /root/ppp: Permission denied

i check files ppp permissions and it is like
-rw-r--r-- 1 root root 251 Oct 26 11:06 ppp
 
Old 11-19-2004, 03:49 AM   #6
cranium2004
Member
 
Registered: Feb 2004
Distribution: FC4,RHEL4
Posts: 223

Rep: Reputation: 30
one more thing both pcs are running sshd i also check that on both pcs

does scp require login as root to execute it? i am doing as root also but fail to transfer file
 
Old 11-19-2004, 04:25 AM   #7
atlesn
Member
 
Registered: Oct 2003
Location: Oslo, Norway
Distribution: RedHat 9.0, Fedora Core 1/2/3, Debian 3.0, Smoothwall
Posts: 110

Rep: Reputation: 15
Are you trying to copy the file to /root/ppp on the other machine?

Past the whole command you used here.

Last edited by atlesn; 11-19-2004 at 10:27 AM.
 
Old 11-19-2004, 04:12 PM   #8
globeTrotter
Member
 
Registered: Feb 2004
Location: Townsville, Queensland, Oz
Distribution: Red Hat 9
Posts: 107

Rep: Reputation: 15
hi


check in your /etc/ssh/sshd_config file for the following

PermitRootLogin no

if it's uncommented, as it should be for security, this then means root can not log in. also check for the comment in the /etc/ssh/ssh_config file. on my system i had to remove it from the ssh_config file for things to work.

sshd_config - is for the server side

ssh_config - is for client side

as a rule don't do anything as root. if you have root priviiliges on the other machine. it's safer to make a copy of files into a user directory and change owner & group. then scp as user. also make shure the sshd service is running on the remote system. obviously if the server is not running it can't serve!.

regards
GT
 
Old 11-20-2004, 03:56 PM   #9
globeTrotter
Member
 
Registered: Feb 2004
Location: Townsville, Queensland, Oz
Distribution: Red Hat 9
Posts: 107

Rep: Reputation: 15
PS

if you can ssh in as root, you should be able to scp as root!!! if you can ssh in as root and not scp, then it's probably a syntax error in your scp command. post the exact scp syntax if this is the case.

regards
GT
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
forwarding secure copy disorderly Linux - Security 5 12-16-2005 11:48 AM
Secure file and passwd transfers lord-fu Linux - Security 5 11-19-2005 12:09 AM
How to copy mysql file into text file lumba General 0 09-26-2005 05:08 AM
secure file deletion shawn59 Linux - Security 2 06-12-2005 09:00 PM
Is arrangement of file systems will differ if we copy a file from FAT 32 to ext 3 ? anindyanuri Linux - Software 2 02-20-2005 11:39 AM


All times are GMT -5. The time now is 03:34 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration