Assume followings:
/mykeys/.ssh/prodserver.pem
- is a certificate file
umid
- is a user name
111.111.111.111
- is a remote host, that mongodb runs
2222
- is a remote port to connect via ssh
localhost:27017
- local host and port on remote machine
27018
- local port
ssh -i /mykeys/.ssh/prodserver.pem [email protected] -p 2222 -Nf -L 27018:localhost:27017
Connect to the mongodb via opened tunnel, in this case mydb
is database name
mongo --port 27018 mydb