Can't solve a simple SSH/scp issue.. Please help.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can't solve a simple SSH/scp issue.. Please help.
# 8  
Old 10-21-2014
SMall correction:

su - user1 -c "scp /tmp/file1 user1@box2:/tmp/file1"

is more likely to work correctly on most systems. Note the spaces around su -
# 9  
Old 10-22-2014
One addendum to Aia'a post above, there is a possibility that the remote authorized keys file is called authorized_keys_2
# 10  
Old 10-22-2014
I vote for
Code:
(
USER=user1
eval HOME=~$USER
export USER HOME
cd $HOME
su $USER -fc "scp /tmp/file1 box2:/tmp/file1" 
)

Not having the isolated - skips the login files. Because some su's don't set USER and HOME we set it beforehand. This is done in a (subshell), so the environment is not changed in the main shell. The -f might skip other shell start files.
Another correction:
The auth key file is authorized_keys or authorized_keys2
# 11  
Old 10-23-2014
Thank you everyone! Even though I'm sure most of the other proposed ways would work also, I ended up adding roots pub key in my target home folders auth file and that solved my issue.

Cheers
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

How to solve TCP connection timeout (not in ssh)?

HI We have some Red Hat Linux Sevres which is having TCP connection timeout, not SSH connection, as an example oracle connection connected from TOD. SSH i managed to add keepalive and it's working fine (1 Reply)
Discussion started by: bentech4u
1 Replies

2. Shell Programming and Scripting

How to solve hang issue in script?

i have one function block in the beginning of my script and there are some commands inside that function which will perform some operations. And i am invoking that function from my main script by passing some values. Sometimes it is hanging in the middle for some value. For example: For 1st... (3 Replies)
Discussion started by: thomasraj87
3 Replies

3. Programming

Removed /root/.cabal by mistake - how to solve this issue?

I have mistakenly removed /root/.cabal/ from my root directoty and when I tried to reinstall it I get this output: faiz:~$ sudo cabal install pandoc --reinstall Resolving dependencies... In order, the following will be installed: pandoc-1.14.0.4 (reinstall) Warning: Note that reinstalls are... (3 Replies)
Discussion started by: faizlo
3 Replies

4. Shell Programming and Scripting

Request to checkVenn diagram issue solve by Unix programm

Hello Any Unix programm can help me to solve thsi issue: I have 2 venn digrams please checke the attached file for pictures of venn diagram for eg red is A yellow is B and green is C..Please see attached file for Venn diagrams In one ..... I have 3 data set A , B and C Venn diagram... (0 Replies)
Discussion started by: manigrover
0 Replies

5. UNIX for Dummies Questions & Answers

Simple Problems to Solve!

Hi, I'm pretty poor at using UNIX but I'm learning. Please help me with these simple problems! Much appreciated! 1. I've changed my shell from bash to csh but I prefer bash. How do I change back? I've tried using chsh -s but it's not working! 2. I'm trying to download TopCat. I've done... (2 Replies)
Discussion started by: SimonWhite
2 Replies

6. Shell Programming and Scripting

simple scp script

simple bash script to scp specific file to another server example: /etc/dir1 (specific file name) then you will just execute a keyword.. sample: ./scp.sh atm*. where atm*. is a sample keyword to search) thanks (0 Replies)
Discussion started by: lhareigh890
0 Replies

7. UNIX for Dummies Questions & Answers

Can anyone solve this awk issue ?

awk -F^ '{ if (($1 != "X") && ($5 != "3")) || if (($1 != "S") && ($5 != "2")) print $0}' abc> xyz The above command returns this error awk: syntax error near line 1 awk: illegal statement near line 1 I am newbie to awk, Any awk intelligence involved in correcting this issue is highly... (2 Replies)
Discussion started by: karthickrn
2 Replies

8. Solaris

please help me solve this issue.........

Hi, I am having a Solaris 5.9 server in which an audit trail script is running every day.It is doing nothing but taking the backup of three files given below -rw-r--r-- 1 root root 1807 May 18 01:30 login_server1_17May2008 -rw-r--r-- 1 root root 0 May 18 01:30... (5 Replies)
Discussion started by: Renjesh
5 Replies

9. Solaris

Help me to solve this issue

Hi, I want to send a .tar file from one solaris 5.9 server to another server in order to make files in sync.What method i can use? (2 Replies)
Discussion started by: Renjesh
2 Replies

10. UNIX for Dummies Questions & Answers

Simple Windows-to-Unix SCP question

Hi, I am fairly new to Unix. My school computers have only UNIX installed on them, and I wish to use them to do some parallel computing. To do so, I need to transfer the files from my Windows computer to my Unix account on a different computer. I am using the SSH login with the Putty client.... (2 Replies)
Discussion started by: Duchesne
2 Replies
Login or Register to Ask a Question