scp files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting scp files
# 1  
Old 01-18-2017
Code scp files

Need assistance

I have ssh keys exchanged between servers for user ZID

ssh works without password between ZID . "ssh SERVER A to SERVER B works"

I have a property file on SERVER A which is owned by root and I need to transfer the file changing into ZID user and transfer to SERVER B

wanted to automate using a script . Need inputs on how I can accomplish this task .
# 2  
Old 01-18-2017
I cannot tell you what you need precisely. Your question needs help

Basically -
If you have sudo, set up your account to have ZID access, no password required.
Code:
sudo - ZID -c "scp /path/local/to/filename serverB:/path/to/file/filename"

If ZID does not have root access on serverB you have other problems to solve. Same as if ZID has no access to the file on serverA.

However, let's go with this. If you have questions:
Please tell us your UNIX/Linux sysyem type (uname -a works well)
It will help us to help you.
This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 01-19-2017
Also, just because a file is owned by root, does not mean that only root can access it! What are its permissions?
# 4  
Old 01-19-2017
Below command works . here is the solution

Code:
root@serverA:/var/tmp# sudo -u ZID scp /var/tmp/samplescp.txt serverB:/var/tmp
samplescp.txt        100% |******************************************************************************************|    54       00:00

# 5  
Old 01-19-2017
Question still stands, what are its permissions? That might not be the simplest solution
# 6  
Old 01-19-2017
Corona688. You were correct when the file has root permission it cannot be transfered , file persmison is 755 root:root.

So In the script we changed the permission of the file to ZID and then using the above command worked. SmilieSmilieSmilieSmilieSmilie
# 7  
Old 01-19-2017
A 755 file can be read, and even executed, by anyone. That was not the problem.

Perhaps the destination file permissions were the problem? Unfortunately, with it having now been overwritten by a potentially new user and new set of permissions already, it is now impossible to answer my question. Keep an eye on whatever uses that file to make sure it's okay with this ownership and permissions.

In the future, "trying users until they work" is not a terrific idea, if you post the file owners and permissions we can tell you in 2 seconds what's preventing a file from being read or overwritten.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Automate splitting of files , scp files as each split completes and combine files on target server

i use the split command to split a one terabyte backup file into 10 chunks of 100 GB each. The files are split one after the other. While the files is being split, I will like to scp the files one after the other as soon as the previous one completes, from server A to Server B. Then on server B ,... (2 Replies)
Discussion started by: malaika
2 Replies

2. UNIX for Dummies Questions & Answers

scp error while trying to copy files

Hi, I am trying to copy files from one server to other using the below code. scp -B -p user@remoteserver:/tmp/abc.txt /landing/files The above command is failing with error You're not allowed to run 'scp -p -f /tmp/abc.txt ' When I am using scp -B -p , why am I getting error msg as scp... (2 Replies)
Discussion started by: Nikhath
2 Replies

3. Shell Programming and Scripting

scp files from subdirectories only.

Hi there, Our current directory structure is set up as follows: -2013-09-20 - 380134664407418202 - 76523.html - 5331257754517660 - 76267.html - 76268.html - 76269.html - 76270.html - 76271.html - 76272.html - 76273.html - 76274.html -... (2 Replies)
Discussion started by: jimbojames
2 Replies

4. Shell Programming and Scripting

rm files after testing for successful scp

First off, I know this is sort of a rehash of similar questions that have been asked in other closed threads, but I haven't been able to figure out how to apply the answers provided in those threads to my scenario and make it work. I am working on a script in KSH on AIX 5.1 that will do a bulk... (1 Reply)
Discussion started by: derndingle
1 Replies

5. UNIX for Dummies Questions & Answers

scp multiple files

Hi, I'm new to Linux. I would like to know how to scp a group of files. I have the below command, but it asks for remote password while sending each file. Is there a way to send all files (identified by - $ ls | grep '.*hrs0314a.*' | xargs -I {} grep -l '.*35663.*' {}) in one go? $ ls |... (6 Replies)
Discussion started by: don_tom
6 Replies

6. Shell Programming and Scripting

copy files using scp without overwriting

Hi, i need to use "scp" to copy a file without overwriting the same in destinations. any suggestion? thanks Sivaji (3 Replies)
Discussion started by: sivarajb
3 Replies

7. Shell Programming and Scripting

scp files from other server with check

Hi all, I am new to this forum,and it has been really a great pleasure to be a part of this forum:) well,i m trying to write a shell script where i m transfering a set of files from other server to my own server. for this i m using scp... (1 Reply)
Discussion started by: prasson_ibm
1 Replies

8. Shell Programming and Scripting

SCP multiple files

Hi , I am doing SCP for copying log files from different server(around 24 server) I need to copy these bulk logfiles every 15 min. How can i do multiple SCP at the same time? My current code is like this scp $CUSTCARE_USER@$CUSTCARE_SERVER:$CUSTCARE_HOME/$CUSTCARE_LOG.*... (2 Replies)
Discussion started by: scorpio
2 Replies

9. Shell Programming and Scripting

scp list of files

Hi, I have to get the list of files from my remote server to my local machine. i tried using such as scp uname@server1:/path/to/dir file1 file2 ./ But i got only the file1 and its saying file2 not found eventhough its there in remote machine. can anyone please help how to get the listed... (1 Reply)
Discussion started by: nmahendran
1 Replies
Login or Register to Ask a Question