Reputation: 731
I have to access my server in such way: localhost -> remote1 -> remote2 (my server)
[xxxx@localhost] $ ssh yyyy@remote1
[yyyy@remote1] $ ssh zzzz@remote2
[zzzz@remote2] $ echo "now I logined into my server..."
I know how to transfer files with scp. however I have no read or write permissions on remote1. How can I transfer a file to remote2?
Upvotes: 1
Views: 697
Reputation: 91017
Another alternative could be to use a Proxy command:
scp -o ProxyCommand='ssh yyy@remote1 netcat %h %p 2> /dev/null' zzz@remote2:fromfile tofile
if remote1
has netcat
installed. Other viable options could be nc
or socat
(the latter has a different syntax).
Upvotes: 2
Reputation: 3097
Try this,
ssh -L localhost:8022:remote2:22 remote1
Now, you can use localhost
port 8022
to contact 22
of remote2
via remote1
. This session session should be active whenever you need to transfer. Use
scp -P 8022 /path/locale/file 127.0.0.1:/path/on/remote2
This is commonly called as SSH Tunneling
. You can search and get to know lot about it.
Upvotes: 1