scp over multiple hops


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting scp over multiple hops
# 1  
Old 08-14-2018
scp over multiple hops

Hi friends,

I am trying to scp a file from server A to Server C via Server B (which is jump host)

from Server A to Server B i have one pem key. from server B to server C I have different Pem key..

what I tried

Code:
scp -r -o ProxyCommand="ssh  -W %h:%p ec2-user@1.4.5.5 dmu.sh ec2-user@1.5.7.4:/home/ec2-user/

Which is not working.. do i need to mention Pem in proxy.. or how I can redefine it with pem keys...

Pls help
# 2  
Old 08-14-2018
Are you sure the command shown is really working? There's at least one double quote missing.

Not sure I know "pem" keys. Could you elaborate a bit?
Usually, I'd log into server B, and then scp the file from server A to server C, making sure the respective keys exist on A, B, and C.
# 3  
Old 08-14-2018
Quote:
Originally Posted by RudiC
Are you sure the command shown is really working? There's at least one double quote missing.

Not sure I know "pem" keys. Could you elaborate a bit?
Usually, I'd log into server B, and then scp the file from server A to server C, making sure the respective keys exist on A, B, and C.
Hi RudiC,

Thanks for reply, that typo double quote missing but still it does not work..

pem key is private authentication key (instead of password authentication) for servers which we use..

All i am trying to copy from A to C by tunnelling via B..

Sorry if this is not the right forum to paste this question..
# 4  
Old 08-14-2018
Generally the way you try it is the way it works.


Quote:
but still it does not work..
What's the error message?

Did you try to run your command with increased verbosity? (ssh -v or even ssh -vv)

Btw.: You need your public key(of server A) placed in authorized_keys of both target hosts(server B+C) for pubkey authentication to work here.


The difference in doing it directly one step after another is that in the manual hopping, user on server a authenticates to user on server b and then user on server b authenticates to server c. With SSH-Proxying, first user on server a authenticates to server b and then user on server a(not b!) authenticates to server c.


You either have to deposit key from server a at server c or import private key from server b to server a, to grant a access to server c, which is not required if you manually login via your jumphost.

Last edited by stomp; 08-14-2018 at 11:07 AM..
This User Gave Thanks to stomp For This Post:
# 5  
Old 08-14-2018
Hmm...at last the below worked can help some one looking for similar issue
Code:
scp -i /home/centos/jumphost.pem -o ProxyCommand="ssh -i /home/centos/jumphost.pem -W %h:%p centos@1.4.5.5" /home/centos/abc.csv ec2-user@1.5.7.4:/home/ec2-user/

# 6  
Old 08-14-2018
... and to for convenient use, place an entry in $HOME/.ssh/config, so you do not have to type this long command line everytime you want to use that proxy connection.


Note

You may delete the key from the Jump-Host as a security measure - if no one else needs the key there. But be sure to have enought backups of the key :-D
# 7  
Old 08-14-2018
Quote:
Originally Posted by stomp
... and to for convenient use, place an entry in $HOME/.ssh/config, so you do not have to type this long command line everytime you want to use that proxy connection.


Note

You may delete the key from the Jump-Host as a security measure - if no one else needs the key there. But be sure to have enought backups of the key :-D
Yes stomp,

I agree, better to put that inot that ssh/config, yes, i wont forget to remove that pem key on jump Smilie Thanks for your input...

The below question is out of this post context..If you have some idea please let me know...

I am trying to ssh into one host with ssh -i abc.pem ec2-user@1.2.3.4
it was working till yesterday..
I just issued a -v option to know what happening...
finally it said permission denied. though i can ping it from other..but not able to login now..it says refused key..
permission on that pem file is 400..so its not too open...-v option not pinpointing issue

any cleanup would help issue. ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

scp multiple files without pattern on Solaris

I need to transfer multiple files using scp between two solaris machines. I could not use pattern since they match with other files in the same directory. I tried the below command, it does not copy any files. $ scp -p user@machine1:/home/fid1/staging/\{a.ksh,b.ksh,c.ksh,d.ksh\} . But... (7 Replies)
Discussion started by: marecar
7 Replies

2. Shell Programming and Scripting

Ssh multiple hops to execute commands with arguments

Hi I need to write a script to ssh through several hops (e.g. HostA-HostB-HostC-HostD), where Host A does not have direct assess to HostC ; HostB cannot access HostD directly. when I ssh 3 hops and run command with arg1, arg2 and redirect the output to a file, e.g. HostA> ssh -t HostB ssh -t... (3 Replies)
Discussion started by: chiensh
3 Replies

3. IP Networking

http over ssh tunnel using multiple hops

Hello, I got an application on a linux server that I would like to access using https and a URL. I would like to create a ssh tunnel. But, let's say the app is on box C, but box C can only be accessed through box B, that can be accessed only through box A. I would like to create the ssh tunnel... (0 Replies)
Discussion started by: Pouchie1
0 Replies

4. 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

5. Solaris

Help with executing multiple remote commands after multiple hops

Hi SSHers, I have embedded this below code in my shell script.. /usr/bin/ssh -t $USER@$SERVER1 /usr/bin/ssh $USER2@S$SERVER2 echo uptime:`/opt/OV/bin/snmpget -r 0 -t 60 $nodeName system.3.0 | cut -d: -f3-5` SSH to both these servers are public-key authenticated, so things run... (13 Replies)
Discussion started by: LinuxUser2008
13 Replies

6. Shell Programming and Scripting

scp command for multiple file transfer.

FILE_LIST="{a.txt,b.txt,cal*}" scp -r $..$REMOTE_PATH$FILE_LIST $LOCAL_PATH This script passes only when all the three files are transfere, wat if only two file are transfered, but still I was to make the return code as pass. is it possible. (2 Replies)
Discussion started by: sangea
2 Replies

7. Shell Programming and Scripting

How to run the multiple scp from single script?

Dear Experts, how to run multiple scp commands from single scripts. In a directory oracle redo files accumulate. i would like to copy those redo logs to my standby server. For same i am using scp to copy the files. where i am monitoring that as it is sending the files sequentially most of... (1 Reply)
Discussion started by: nmadhuhb
1 Replies

8. Shell Programming and Scripting

SSHing with multiple hops

Hi, I have got a shell script, which fails to run properly.. I am getting the following error: "Pseudo-terminal will not be allocated because stdin is not a terminal. Permission denied (gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive)." I SSH to the machine and then run the... (1 Reply)
Discussion started by: LinuxUser2008
1 Replies

9. Shell Programming and Scripting

Script to SCP a file to multiple servers

Hi All, I am a total noob to the Unix world, and i hope to learn a lot from this wonderful community. Here's my first post and question , i am trying to SCP a file to multiple servers (multiple destinations) through this little script : #!/bin/ksh # copy files # File to be copied... (7 Replies)
Discussion started by: rdlover
7 Replies

10. 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
Login or Register to Ask a Question