How to SSH via intermediate server [duplicate]
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
1
down vote
favorite
This question already has an answer here:
Correct ssh config file settings to tunnel to a 3rd machine
2 answers
Three server A,B & C. How to ssh
connect from A to C via intermediate server B, if A to B & C to B are password less(key)? I encountered this in an interview. Anyone knows how?
linux ssh openssh
marked as duplicate by Jakuje, MelBurslan, jimmij, Anthon, Rui F Ribeiro Jun 15 '16 at 19:56
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
1
down vote
favorite
This question already has an answer here:
Correct ssh config file settings to tunnel to a 3rd machine
2 answers
Three server A,B & C. How to ssh
connect from A to C via intermediate server B, if A to B & C to B are password less(key)? I encountered this in an interview. Anyone knows how?
linux ssh openssh
marked as duplicate by Jakuje, MelBurslan, jimmij, Anthon, Rui F Ribeiro Jun 15 '16 at 19:56
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Anyway, how do you want to connect to C, when you don't have the authentication there from B nor from A? There is probably some of the context missing, because at this time it does not make much sense, unless they wanted to hear from you about the remote port forwarding.
â Jakuje
Jun 15 '16 at 19:27
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
This question already has an answer here:
Correct ssh config file settings to tunnel to a 3rd machine
2 answers
Three server A,B & C. How to ssh
connect from A to C via intermediate server B, if A to B & C to B are password less(key)? I encountered this in an interview. Anyone knows how?
linux ssh openssh
This question already has an answer here:
Correct ssh config file settings to tunnel to a 3rd machine
2 answers
Three server A,B & C. How to ssh
connect from A to C via intermediate server B, if A to B & C to B are password less(key)? I encountered this in an interview. Anyone knows how?
This question already has an answer here:
Correct ssh config file settings to tunnel to a 3rd machine
2 answers
linux ssh openssh
edited Jun 15 '16 at 19:55
Jakuje
15.6k52850
15.6k52850
asked Jun 15 '16 at 18:26
user2700022
61
61
marked as duplicate by Jakuje, MelBurslan, jimmij, Anthon, Rui F Ribeiro Jun 15 '16 at 19:56
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Jakuje, MelBurslan, jimmij, Anthon, Rui F Ribeiro Jun 15 '16 at 19:56
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Anyway, how do you want to connect to C, when you don't have the authentication there from B nor from A? There is probably some of the context missing, because at this time it does not make much sense, unless they wanted to hear from you about the remote port forwarding.
â Jakuje
Jun 15 '16 at 19:27
add a comment |Â
Anyway, how do you want to connect to C, when you don't have the authentication there from B nor from A? There is probably some of the context missing, because at this time it does not make much sense, unless they wanted to hear from you about the remote port forwarding.
â Jakuje
Jun 15 '16 at 19:27
Anyway, how do you want to connect to C, when you don't have the authentication there from B nor from A? There is probably some of the context missing, because at this time it does not make much sense, unless they wanted to hear from you about the remote port forwarding.
â Jakuje
Jun 15 '16 at 19:27
Anyway, how do you want to connect to C, when you don't have the authentication there from B nor from A? There is probably some of the context missing, because at this time it does not make much sense, unless they wanted to hear from you about the remote port forwarding.
â Jakuje
Jun 15 '16 at 19:27
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
1
down vote
You are in server A:
ssh user@serverB ssh user@serverC
Or you can use proxy command (see here for more info Proxies and Jump Hosts) as follows:
Create a config file under ~/.ssh
in server A
with following data:
Host serverC
HostName serverC
User user
ProxyCommand ssh -l user serverB -W %h:%p
Then you can just user ssh serverC
to reach it from serverA
via serverB
.
This article is very outdated. You should useProxyCommand
with thessh -W
switch, rather than thenc
.
â Jakuje
Jun 15 '16 at 18:39
@Jakuje OK, updated link! Seems the wiki is up to date enough.
â coffeMug
Jun 15 '16 at 18:42
@coffeMug I understood the first method, can you please elaborate on using with proxy? if possible with eg?
â user2700022
Jun 15 '16 at 18:51
@coffeMug I tried out your 1st solution, it will work only if B->C also is password less isn't ? here in my case A->B & C->B are password less. but not B-> C.
â user2700022
Jun 15 '16 at 19:02
@user2700022 it should ask you for password.
â coffeMug
Jun 15 '16 at 19:05
add a comment |Â
up vote
0
down vote
@coffeMug I tried out your 1st solution, it will work only if B->C
also is password less isn't ? here in my case A->B & C->B are password
less.but not B-> C.
Maybe, and only maybe C have a config allowing A, but does not communicate directly to A, requiring the middle server B only for the network communication. If that is true. iptables on server B using the table nat can do something for you.
Sorry i tried to help... so give it a try, is the only possibility, because in all others it will ask you for a password, because B->C no-password is required to this get working using ssh only.
add a comment |Â
up vote
0
down vote
The original question does not make much sense. But I can guess they wanted to ask about the servers A and C in private networks (so they do not "see" each other) and B visible to both of them. In this case, the answer is Remote Port Forwarding. With example:
Create a tunnel B->C from C:
C$ ssh -R 2222:localhost:22 B
and then connecting from A to C like this:
A$ ssh A ssh -p 2222 localhost
Or in more elegant way with ssh_config
. You will have to certainly write the password to connect to the server C (localhost:2222 from B), if there is not set up pubkey authentication, but that should not be a problem.
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
You are in server A:
ssh user@serverB ssh user@serverC
Or you can use proxy command (see here for more info Proxies and Jump Hosts) as follows:
Create a config file under ~/.ssh
in server A
with following data:
Host serverC
HostName serverC
User user
ProxyCommand ssh -l user serverB -W %h:%p
Then you can just user ssh serverC
to reach it from serverA
via serverB
.
This article is very outdated. You should useProxyCommand
with thessh -W
switch, rather than thenc
.
â Jakuje
Jun 15 '16 at 18:39
@Jakuje OK, updated link! Seems the wiki is up to date enough.
â coffeMug
Jun 15 '16 at 18:42
@coffeMug I understood the first method, can you please elaborate on using with proxy? if possible with eg?
â user2700022
Jun 15 '16 at 18:51
@coffeMug I tried out your 1st solution, it will work only if B->C also is password less isn't ? here in my case A->B & C->B are password less. but not B-> C.
â user2700022
Jun 15 '16 at 19:02
@user2700022 it should ask you for password.
â coffeMug
Jun 15 '16 at 19:05
add a comment |Â
up vote
1
down vote
You are in server A:
ssh user@serverB ssh user@serverC
Or you can use proxy command (see here for more info Proxies and Jump Hosts) as follows:
Create a config file under ~/.ssh
in server A
with following data:
Host serverC
HostName serverC
User user
ProxyCommand ssh -l user serverB -W %h:%p
Then you can just user ssh serverC
to reach it from serverA
via serverB
.
This article is very outdated. You should useProxyCommand
with thessh -W
switch, rather than thenc
.
â Jakuje
Jun 15 '16 at 18:39
@Jakuje OK, updated link! Seems the wiki is up to date enough.
â coffeMug
Jun 15 '16 at 18:42
@coffeMug I understood the first method, can you please elaborate on using with proxy? if possible with eg?
â user2700022
Jun 15 '16 at 18:51
@coffeMug I tried out your 1st solution, it will work only if B->C also is password less isn't ? here in my case A->B & C->B are password less. but not B-> C.
â user2700022
Jun 15 '16 at 19:02
@user2700022 it should ask you for password.
â coffeMug
Jun 15 '16 at 19:05
add a comment |Â
up vote
1
down vote
up vote
1
down vote
You are in server A:
ssh user@serverB ssh user@serverC
Or you can use proxy command (see here for more info Proxies and Jump Hosts) as follows:
Create a config file under ~/.ssh
in server A
with following data:
Host serverC
HostName serverC
User user
ProxyCommand ssh -l user serverB -W %h:%p
Then you can just user ssh serverC
to reach it from serverA
via serverB
.
You are in server A:
ssh user@serverB ssh user@serverC
Or you can use proxy command (see here for more info Proxies and Jump Hosts) as follows:
Create a config file under ~/.ssh
in server A
with following data:
Host serverC
HostName serverC
User user
ProxyCommand ssh -l user serverB -W %h:%p
Then you can just user ssh serverC
to reach it from serverA
via serverB
.
edited Jun 15 '16 at 19:04
answered Jun 15 '16 at 18:35
coffeMug
6,50892345
6,50892345
This article is very outdated. You should useProxyCommand
with thessh -W
switch, rather than thenc
.
â Jakuje
Jun 15 '16 at 18:39
@Jakuje OK, updated link! Seems the wiki is up to date enough.
â coffeMug
Jun 15 '16 at 18:42
@coffeMug I understood the first method, can you please elaborate on using with proxy? if possible with eg?
â user2700022
Jun 15 '16 at 18:51
@coffeMug I tried out your 1st solution, it will work only if B->C also is password less isn't ? here in my case A->B & C->B are password less. but not B-> C.
â user2700022
Jun 15 '16 at 19:02
@user2700022 it should ask you for password.
â coffeMug
Jun 15 '16 at 19:05
add a comment |Â
This article is very outdated. You should useProxyCommand
with thessh -W
switch, rather than thenc
.
â Jakuje
Jun 15 '16 at 18:39
@Jakuje OK, updated link! Seems the wiki is up to date enough.
â coffeMug
Jun 15 '16 at 18:42
@coffeMug I understood the first method, can you please elaborate on using with proxy? if possible with eg?
â user2700022
Jun 15 '16 at 18:51
@coffeMug I tried out your 1st solution, it will work only if B->C also is password less isn't ? here in my case A->B & C->B are password less. but not B-> C.
â user2700022
Jun 15 '16 at 19:02
@user2700022 it should ask you for password.
â coffeMug
Jun 15 '16 at 19:05
This article is very outdated. You should use
ProxyCommand
with the ssh -W
switch, rather than the nc
.â Jakuje
Jun 15 '16 at 18:39
This article is very outdated. You should use
ProxyCommand
with the ssh -W
switch, rather than the nc
.â Jakuje
Jun 15 '16 at 18:39
@Jakuje OK, updated link! Seems the wiki is up to date enough.
â coffeMug
Jun 15 '16 at 18:42
@Jakuje OK, updated link! Seems the wiki is up to date enough.
â coffeMug
Jun 15 '16 at 18:42
@coffeMug I understood the first method, can you please elaborate on using with proxy? if possible with eg?
â user2700022
Jun 15 '16 at 18:51
@coffeMug I understood the first method, can you please elaborate on using with proxy? if possible with eg?
â user2700022
Jun 15 '16 at 18:51
@coffeMug I tried out your 1st solution, it will work only if B->C also is password less isn't ? here in my case A->B & C->B are password less. but not B-> C.
â user2700022
Jun 15 '16 at 19:02
@coffeMug I tried out your 1st solution, it will work only if B->C also is password less isn't ? here in my case A->B & C->B are password less. but not B-> C.
â user2700022
Jun 15 '16 at 19:02
@user2700022 it should ask you for password.
â coffeMug
Jun 15 '16 at 19:05
@user2700022 it should ask you for password.
â coffeMug
Jun 15 '16 at 19:05
add a comment |Â
up vote
0
down vote
@coffeMug I tried out your 1st solution, it will work only if B->C
also is password less isn't ? here in my case A->B & C->B are password
less.but not B-> C.
Maybe, and only maybe C have a config allowing A, but does not communicate directly to A, requiring the middle server B only for the network communication. If that is true. iptables on server B using the table nat can do something for you.
Sorry i tried to help... so give it a try, is the only possibility, because in all others it will ask you for a password, because B->C no-password is required to this get working using ssh only.
add a comment |Â
up vote
0
down vote
@coffeMug I tried out your 1st solution, it will work only if B->C
also is password less isn't ? here in my case A->B & C->B are password
less.but not B-> C.
Maybe, and only maybe C have a config allowing A, but does not communicate directly to A, requiring the middle server B only for the network communication. If that is true. iptables on server B using the table nat can do something for you.
Sorry i tried to help... so give it a try, is the only possibility, because in all others it will ask you for a password, because B->C no-password is required to this get working using ssh only.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
@coffeMug I tried out your 1st solution, it will work only if B->C
also is password less isn't ? here in my case A->B & C->B are password
less.but not B-> C.
Maybe, and only maybe C have a config allowing A, but does not communicate directly to A, requiring the middle server B only for the network communication. If that is true. iptables on server B using the table nat can do something for you.
Sorry i tried to help... so give it a try, is the only possibility, because in all others it will ask you for a password, because B->C no-password is required to this get working using ssh only.
@coffeMug I tried out your 1st solution, it will work only if B->C
also is password less isn't ? here in my case A->B & C->B are password
less.but not B-> C.
Maybe, and only maybe C have a config allowing A, but does not communicate directly to A, requiring the middle server B only for the network communication. If that is true. iptables on server B using the table nat can do something for you.
Sorry i tried to help... so give it a try, is the only possibility, because in all others it will ask you for a password, because B->C no-password is required to this get working using ssh only.
answered Jun 15 '16 at 19:26
Luciano Andress Martini
2,628725
2,628725
add a comment |Â
add a comment |Â
up vote
0
down vote
The original question does not make much sense. But I can guess they wanted to ask about the servers A and C in private networks (so they do not "see" each other) and B visible to both of them. In this case, the answer is Remote Port Forwarding. With example:
Create a tunnel B->C from C:
C$ ssh -R 2222:localhost:22 B
and then connecting from A to C like this:
A$ ssh A ssh -p 2222 localhost
Or in more elegant way with ssh_config
. You will have to certainly write the password to connect to the server C (localhost:2222 from B), if there is not set up pubkey authentication, but that should not be a problem.
add a comment |Â
up vote
0
down vote
The original question does not make much sense. But I can guess they wanted to ask about the servers A and C in private networks (so they do not "see" each other) and B visible to both of them. In this case, the answer is Remote Port Forwarding. With example:
Create a tunnel B->C from C:
C$ ssh -R 2222:localhost:22 B
and then connecting from A to C like this:
A$ ssh A ssh -p 2222 localhost
Or in more elegant way with ssh_config
. You will have to certainly write the password to connect to the server C (localhost:2222 from B), if there is not set up pubkey authentication, but that should not be a problem.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
The original question does not make much sense. But I can guess they wanted to ask about the servers A and C in private networks (so they do not "see" each other) and B visible to both of them. In this case, the answer is Remote Port Forwarding. With example:
Create a tunnel B->C from C:
C$ ssh -R 2222:localhost:22 B
and then connecting from A to C like this:
A$ ssh A ssh -p 2222 localhost
Or in more elegant way with ssh_config
. You will have to certainly write the password to connect to the server C (localhost:2222 from B), if there is not set up pubkey authentication, but that should not be a problem.
The original question does not make much sense. But I can guess they wanted to ask about the servers A and C in private networks (so they do not "see" each other) and B visible to both of them. In this case, the answer is Remote Port Forwarding. With example:
Create a tunnel B->C from C:
C$ ssh -R 2222:localhost:22 B
and then connecting from A to C like this:
A$ ssh A ssh -p 2222 localhost
Or in more elegant way with ssh_config
. You will have to certainly write the password to connect to the server C (localhost:2222 from B), if there is not set up pubkey authentication, but that should not be a problem.
answered Jun 15 '16 at 19:54
Jakuje
15.6k52850
15.6k52850
add a comment |Â
add a comment |Â
Anyway, how do you want to connect to C, when you don't have the authentication there from B nor from A? There is probably some of the context missing, because at this time it does not make much sense, unless they wanted to hear from you about the remote port forwarding.
â Jakuje
Jun 15 '16 at 19:27