0

I have a Linux server (A) (With IP X.X.X.X) that's accept SSH (in port X) only from another Linux server (B) with specific IP Y.Y.Y.Y. Obviously, if I login in the server B (From whatever IP) I can SSH the server A.

It is possible to access the server A through server B using a routing or forwarding from any IP?

I'm expecting to open a SSH connection in a specific port in server B and this will route the traffic to server A

h2odev
  • 113

2 Answers2

1

I think that what you are looking for is called SSH Bastion and you can easily configure it by creating a ssh config file inside you .ssh directory. A good description is here: https://goteleport.com/blog/ssh-bastion-host/

Something like this shall made the trick (assuming that you want to connect to to server A from server C, you create a config file in server C):

$ cat ~/.ssh/config
Host X.X.X.X
   User serverAusername
   ProxyJump Y.Y.Y.Y

make sure that server B /etc/ss/sshd_config file has the correct settings as per the above link.

Hope this helps :-)

0

One of the ways to solve this case is using nginx upstream in server B.

First, make sure to load the nginx stream module

load_module '/usr/lib64/nginx/modules/ngx_stream_module.so';

And add the proxy configuration as below:

stream  {
    upstream ssh {
        server {server-a-ip}:22;
    }
server  {
    listen {my-non-standard-port};
    proxy_pass ssh;
}

}

Then you can connect to server A:

ssh username@{server-b-ip} -p {my-non-standard-port}

Of course, better allow only your public IPs to access the server B in port {my-non-standard-port}

h2odev
  • 113