Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

cannot copy local files to remote computer thru ssh

Posted on 2013-01-18
14
Medium Priority
?
758 Views
Last Modified: 2013-12-16
I am getting trouble copying local files to remote files on a linux machine.  I am using scp in ssh to copy files but local files doesnt seems found although they are there.

logged in by ssh
ssh user1@pdevdv2db166.corp.company.com
pwd : blahblah

I want to copy all htlocations.txt from my local machine to remote machine
scp    htlocations.txt    user1@pdevdv2db166.corp.company.com:/export/home/user1
===   ===========   ==================================================

But I keep getting the error that htlocations.txt is not found, I have tried by changing it to export/users/user1/htlocations.txt  and also copied the htlocations.txt at export/users/user1 folder in my local mac

Even when I switch the source and target like copy remote files to local machine that doesnt work either, it keep saying that
scp ysingh@pdevdv2db166.corp.intuit.net:/export/home/ysingh/*.txt Users/user1/Dev/
It keep complaining that Users/user1/Dev : No such file or directory


Could someone please help. I heard that scp is really easy to use, not sure why it is not working for me.   I am accessting a remote VM thru my mac.
0
Comment
Question by:ysgdel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
14 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 38795675
Do you mean /export/users/user1/htlocations.txt ? or /Users/user1/Dev/ ?
0
 

Author Comment

by:ysgdel
ID: 38796439
Neither of these. I tried my files putting at Users/user1/Dev/htlocations.txt  or in directly my home directory Users/user1  or also put the file in /export/users/user1... but scp doesnt find files anywhere. Instead it seems look files on remote computer so technically if I say copy *.txt files to remote computer... it copy the *.txt from remote computer itself to remote computer. But I wanted files to be picked up from my local computer and then copy to remote computer.   How do I copy local files?  Do I put files at a specific location in my local computer?
0
 
LVL 84

Expert Comment

by:ozo
ID: 38796479
Unless you cd to /
 Users/user1/Dev/htlocations.txt
is different from
 /Users/user1/Dev/htlocations.txt

 If path is not a full path name, it is interpreted relative to the login directory of the specified user ruser on rhost, or your current user name if no other remote user
     name is specified.
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:ysgdel
ID: 38797683
Ozo I know that when relative path applies. The same logic applies on copying files locally

The problem is with scp when I specify any file whether it is in current directory or in subdirectory, scp never finds it, it always say No such file.  I ssh right from my user's home and the files which are in user's home, those are not found. There has to be something to find that.  Like below : htlocations.txt is right in same directory but not found.

scp    htlocations.txt    user1@pdevdv2db166.corp.company.com:/export/home/user1
0
 
LVL 84

Expert Comment

by:ozo
ID: 38797705
Does scp say No such file if you give the full path name?
0
 

Author Comment

by:ysgdel
ID: 38802302
Yes  I tried both ways...
0
 
LVL 47

Expert Comment

by:David
ID: 38828227
You may have hidden characters in the file name.  Remember, this is unix, so even a ctrl-h or delete key can be part of a file name.  

Try using wild-cards, or better yet, just do a simple test from command line and cp htlocations.txt  test1.txt

Then try to copy test1.txt

Also, since nobody mentioned permissions, why not just for grins chmod 666 the file and chown nobody:nobody and see if that helps.
0
 
LVL 22

Expert Comment

by:blu
ID: 38828542
Try running these two commands in the same directory you ran the scp command in:

ls -l htlocations.txt

ssh user1@pdevdv2db166.corp.company.com "ls -l /export/home/user1"
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 38828816
silly question, did you probably want to do it this direction?

no logged in by ssh to user1@pdevdv2db166.corp.company.com
scp    htlocations.txt    user1@pdevdv2db166.corp.company.com:/export/home/user1
0
 
LVL 21

Accepted Solution

by:
Daniel McAllister earned 2000 total points
ID: 38835416
I have to agree with dlethe... my first suspicion is that there is a permissions or hidden character issue going on here...

My own preferred way to address that kind of thing is that I rely heavily on bash's tab-completion feature:

Try typing "scp htloc[tab]" and see what happens...

Assuming you're not "root" in typing the scp command, you might also want to look into whether you have the appropriate read permission on the source file -- and execute permission on the source file's directory.

If you are root (shame on you! <grin>), and the file still appears to be unreadable by scp (but works with the likes of cp), look at the executable file itself for scp (ls -l `which scp`) -- it may be running as suid or there may be something else "funky" going on there...

scp really is a VERY simple command -- and since your error message has to do with reading the source, it's not time (yet) to go digging into the target machine... error messages are usually correct from the perspective of the program throwing the error message at that point in its processing....

I hope this helps...


Dan
IT4SOHO
0
 
LVL 35

Expert Comment

by:Duncan Roe
ID: 38846074
Does the remote directory exist? Maybe scp is complaining about that, rather than the local file. What is the exact error message it prints?
0
 

Expert Comment

by:mesmeridze
ID: 38859962
Try to do
cp htlocations.txt /dev/null
And see if there any error.
Than connect to pdevdv2db166.corp.company.com server and check is there folder you trying to copy to
ls -ld /export/home/user1
0

Featured Post

CHALLENGE LAB: Troubleshooting Connectivity Issues

Goal: Fix the connectivity issue in the lab's AWS environment so that you can SSH into the provided EC2 instance.  

Question has a verified solution.

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

Online collaboration is quickly becoming embedded in the workplace, and its benefits are tangible. See what the current landscape looks like and what the future holds for collaboration tools and the future of work.
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

715 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