24 votes
Accepted

SSH access gateway for many servers

That's too complicated (checking if a key has access to a specific prod server). Use the gateway server as jump host that accepts every valid key (but can easily remove access for a specific key ...
  • 98.1k
23 votes
Accepted

ssh -R make target host accept connection on all interfaces

By default, it will listen on localhost (loopback interface) only. You need to specify the bind_address as 0.0.0.0 in your command: ssh -R 0.0.0.0:2222:localhost:22 TARGET -N You need also to ...
  • 36.2k
22 votes
Accepted

How can I use port tunneling to connect to a private database instance through a network bastion?

When you create an SSH tunnel, it does not expose the opened port to the outside world. The opened port, is only available as localhost. So effectively what you've done is to create a tunnel from your ...
  • 9,904
19 votes

How to add local forward setting to my ssh config file?

I think, you have differently defined command and config. In command, you are using localhost and in config, IP address (12.34.56.78). This should works for you: Host myhost User myuser ...
  • 291
16 votes

Forward SSH through SSH tunnel

As of OpenSSH 7.3 (late 2016) the easiest way is the ProxyJump setting. In your ~/.ssh/config: Host B ProxyJump A Or on the command line, -J B.
  • 291
14 votes
Accepted

SSH: What's the difference between -L and -R?

It's right there, in the man page: -L Specifies that connections to the given TCP port or Unix socket on the local (client) host are to be forwarded to the given host and port, or Unix socket, on the ...
13 votes

What is the difference between Local/Remote/Dynamic SSH tunneling?

I have drawn some sketches The machine, where the ssh tunnel command is typed (or in your case: Putty with tunneling is started) is called »your host«. static (options -L local and -R remote) local: ...
  • 261
13 votes
Accepted

ssh -R binds to 127.0.0.1 only on remote

While the local optional bind address is at the control of SSH's client side (specified with -L/LocalForward or altered with -g/GatewayPorts in the client's configuration), the remote optional bind ...
  • 9,670
12 votes
Accepted

SSH config ProxyCommand asks for public key

ProxyCommand doesn't work the way you think it does. The command specified is not run on the gateway machine. Rather, it is run on the connecting machine. The flow of execution is therefore: The ...
11 votes

SSH access gateway for many servers

Engineers should not be running ansible directly from their laptop, unless this is a dev/test environment. Instead, have a central server that pulls the runbooks from git. This allows for additional ...
10 votes

Copying SSH IDs between servers

Is it good practice to copy SSH IDs a la ssh-copy-id between remote servers in production, so that they can perform various SSH tasks with one another easier? Yes, absolutely. Keep separate keys ...
  • 109k
10 votes
Accepted

How to SSH tunnel with keys

Despite the authentication method used, SSH tunneling works the same way. The problem here is not about using public key authentication but understanding the basics of How to Use SSH Tunneling. Your -...
  • 44.8k
9 votes
Accepted

RDP equivalent to SSH port forwarding?

No, it is not possible with RDP. You can install an SSH server on windows and continue to use SSH. Alternatively, you can use netsh to do TCP forwarding as described in this answer on SO: netsh ...
9 votes
Accepted

Add temporary entry to hosts, when tunnelling SSH

I have a solution for you, wrap your ssh command into a bash script: #!/bin/bash function control_c { echo -en "\n## Caught SIGINT; Clean up /etc/hosts and Exit \n" sed -i '' "/internal-wiki/...
  • 1,700
9 votes
Accepted

SSH Local Port forwarding working from localhost only

Are you aware that you type 4122 in the example? You should try -L *:4420:172.88.3.31:22 The star implies that you listen on all addresses, and not localhost, which you cannot connect to from ...
  • 173
8 votes

how to solve the "open failed: administratively prohibited: open failed" when using a SSH tunnel proxy

There is a broader discussion of this error with SSH tunnels on Unix StackExchange. In a nutshell, this is a non-specific error; there are numerous possibilities that should be explored.
  • 129
8 votes

Forward SSH through SSH tunnel

according to the ssh man page, ProxyCommand is the correct method the syntax being: ProxyCommand ssh -W %h:%p user@jumphost 2> /dev/null
8 votes

Tunneling cassandra via ssh gives me a connection closed error

You need to proxy both port 9160 (Cassandra Client port) and port 9042 (CQL native port). Either run two terminals or make the ssh client go background with these flags: ssh -f -N -q -L 9042:192.XXX....
  • 181
8 votes

Access web service behind jump host via ssh tunnel

ssh -L 8192:192.0.2.3:8192 198.51.100.7 then access http://localhost:8192/ What this does is: -L = Listen on a local port (where the ssh client is running) 8192 = Listen on port 8192 192.0.2.3:8192 = ...
8 votes
Accepted

Sharing SSH port tunnel with local network

You need to modify your command to specify bind_address like: ssh -N -f -L 0.0.0.0:5431:localhost:xxxx mycloudserver.com This will make it listen on all interfaces. To verify, use: netstat -lnp | ...
  • 36.2k
8 votes
Accepted

Connection to postgresql hangs over SSH tunnel on OSX

I believe you have postgresql configured to listen only on loopbavk (localhost). You should use the forwarding like this: ssh -L 5433:localhost:5432 user@serverip Otherwise it will try to connect to ...
  • 9,465
8 votes
Accepted

Working example of multiple permitopen options in authorized_keys

I've gotten it to work. The first example above works. permitopen="host-1:3389",permitopen="host-2:3389" ssh-rsa AAAAC... In my case it was not working because the host name is case-sensitive. I ...
7 votes

with SSH only: reverse tunnel web access via ssh SOCKS proxy

Newer versions of SSH allow to use the very simple option of ssh -R <[bind_address:]port>. Using only the port on the host and maybe the bind address, but not specifying the client side port ...
7 votes
Accepted

How to add local forward setting to my ssh config file?

The syntax of the ssh_config file was correct - so the error had to be somewhere else. The command line which worked was: ssh 12.34.56.78 -L 8888:localhost:8000 but in the LocalForward directive, you ...
  • 2,119
7 votes
Accepted

Is it possible to have multiple users SSH tunnel to a same local port?

Definitely. You can easily try this with your own user. Just open up two terminals and start two SSH sessions to proxy that same server port. Session #1: ssh -L 8080:127.0.0.1:80 ssh-user@server....
  • 86
6 votes

how to tunnel Windows Remote Desktop through ssh using a linux box?

One can use internal ssh tunneling from Remmina remote desktop client too. If you can ssh to some linux server using ssh keys and that server have open 3389 (RDP) port for packets coming from your ...
  • 493
6 votes

SSH Reverse Port Forward Bind to address

In order to make it bind to all interfaces, use: ssh -N -R 0.0.0.0:2695:localhost:22 root@example.com Don't forget to edit /etc/ssh/sshd_config and go to GatewayPorts and enable it and set it to ...
6 votes

SSH connecting on port 22 but times out on 443

When you telnet (or nc) to a port that has an ssh server listening, you should obtain a string of characters, something like SSH-2.0-OpenSSH_6.0p1 Debian-4+deb7u2 If you don't obtain a string like ...
  • 3,527
6 votes

set up secure connection over SSH

You're connecting to tcp my.server.com:5000, it runs ssh subsystem "app" there. What is being performed is defined by that subsystem (in the ssh server config file). That subsystems could transfer ...
6 votes

Is there any way to log entered password from ssh?

You can visualize the failed user names after you turn up the verbosity of the log in sshd_config¹, but there is no way to see the failed passwords as this could be a potential security issue and ...
  • 9,465

Only top scored, non community-wiki answers of a minimum length are eligible