I'm using WinSSHTerm to connect to a proxy, from which I then connect to a server hosting a data warehouse. I just can't figure out how to reproduce my Putty connection using a shell command.
Short recap:
I first connect to the proxy server which maps the port 5432 to my local port 10001. After that, i connect to the database server and map its 5432 port to my proxy's 5432 port, which I previously mapped to my 10001 port locally. I am then able to connect to the databse via a database manager locally.
To do so:
I created the following connection to my proxy server first.
I then added a tunnel from there to my localhost port 10001.
Once I'm logged in to the proxy server, I use the following command to connect to the database server and map its 5432 port to the proxy's 5432 port.
ssh username#databaseServer -L 127.0.0.1:5432:databaseServer:5432
I'd like to leave putty and move to WinSSHterm, predefine some login commands for a specific server.
How may I reproduce the behavior above using a shell command?
Here's my initial try, which is unfortunately not working:
ssh username#databaseServer -L 127.0.0.1:5432:databaseServer:5432
Thank you
I was finally able to find the correct way to write it.
Loginc Cmds
ssh username#databaseServer -L 127.0.0.1:5432:databaseServer:5432
Cmd-line Args
-L 10001:localhost:5432
Related
i actually use a dbeaver client to connect to a remote Postgres database.
dbeaver client use a bastion, by creating a ssh tunnel between localhost and bastion
(and then, bastion is connected to the database).
We have something like that
localhost (dBeaver) --> bastion --> postgres database
to make a backup of my database, dbeaver client use a command like :
pg_dump --verbose --host=127.0.0.1 --port=59914 --username=my-user --format=c -t public.dashboard my-database > /dump.sql
so, i deduce that dbeaver created a tunnel between my localhost 55914 to the remote port of the postgres database (5432)
All is well and works perfectly, but i'd like to understand how dbeaver created the ssh tunnel.
How can we check in Linux that it exist an opened tunnel from my 59914 local port to the remote postgres database, using interdemediary bastion machine ?
What is the command line to check that ?
The next picture was used to create a tunnel with mobaxterm:
Does anyone knows the meaning? also, how can I do to translate this into Ubuntu Linux ssh command to create the tunnel specified by the picture?. I need this to connect to my db.
Thx
That looks roughly like
ssh myusername#grv.soccer.cpu.edu -p 7822 -L 1338:172.178.0.12:3338
which basically means: connect to grv.soccer.cpu.edu using username myusername, the server is using port 7822 instead of the default port 22 and, while you are it, put local port 1338 in LISTEN and tunnel-it to port 3338 of server/IP 172.178.0.12; after you've successfully connected to the grv.soccer.cpu.edu you'll have the service running on 172.178.0.12:3338 directly reachable locally on/at 127.0.0.1:1338.
I have remote host/server with ssh access.
I have my computer in my work network which can connect via ssh only
in within this network.
And i can not connect via ssh to other world because of port 22
blocked by firewall.
I am trying to create ssh tunnel to forward example localhost:80 to remote_server:22.(i suppose to connect via ssh to localhost and will be forwarded to my remote server)
I tried for example without proxy
sudo ssh -L localhost:443:remote_server_ip:22 root#remote_host_name
and with proxy
https://wiki.archlinux.org/index.php/Tunneling_SSH_through_HTTP_proxies_using_HTTP_Connect
I have read a lot and checked stackoverflow but it still is not clear for me how to resolve this issue.
I'm using SSH tunneling for the first time, so I'm trying to understand how to configure it.
I've got a remote Linux server that hosts a MySQL database that I'm trying to connect to. In order to access the MySQL database directly through a software that only recognizes local databases, I suppose SSH tunneling would be the right way to set up the access, correct?
Now, I'm trying to set up the tunneling on my 'home' computer which is running the software that's trying to access the MySQL database. My first question is whether this is reverse tunneling or normal tunneling? Secondly, is it local tunneling or remote tunneling?
Finally, from what I understand, my code is supposed to look something like
ssh -L 8080:mylinuxserver.mycompany.com:22 myuser#mylinuxserver.mycompany.com
Is this correct? Is my source port '22' since I'm using SSH and is my destination port 8080 (or is there something more appropriate)?
When I try to use the above code, I am able to login using my passphrase (since my key is already in the MyLinuxServer) but when I ping localhost:8080, it cannot find the host.
What am I doing wrong?
I've got a remote Linux server that hosts a MySQL database that I'm trying to connect to
The command should be:
ssh -L 8080:localhost:3306 myuser#mylinuxserver.mycompany.com
Where:
8080: is hte local port on your workstation
localhost: is corresponding to mylinuxserver.mycompany.com
3306: the MySQL port on above localhost.
then connect (from your workstation) to MySQL as:
mysql -h 127.0.0.1 --port=8080
Besides, ping localhost:8080 is wrong. Ping cannot work that way.
Try this:
ssh -f ssh_user#mylinuxserver.mycompany.com -L 3307:mysql1.example.com:3306 -N
Next, to access the mysql your trying to connect to:
mysql -h 127.0.0.1 -P 3307
Setup:
My computer (linux / unix) has an arbitrary IP address
I can connect to a central linux server which has a static ip
Remote linux systems are set up so they only respond to central server IP address on port 22
I want to port forward through the central server so I can use MySQLWorkbench and make python scripting connections on port 3306 to the remote systems.
Ideally, I would like the syntax for ssh command to make the port forwarding work;
Suppose I want to forward local port 3307 to 3306 on the remote system. Assume my ip is x.x.x.x, the central server IP is y.y.y.y, and the remote system IP is z.z.z.z;
I think it has something to do with ssh -L but I can only forward to the central server so far. Maybe I need to connect to the central server, set up forwarding there, then set up forwarding on my machine? I think functionality exists to do it with a single command using ssh.
If this is a duplicate, it should not be marked as such because without knowing what magic keyword to search for, you can't find the duplicate;
Clarification: port 3306 is NOT open on the remote server. Only 22
ssh -L :3307:z.z.z.z:3306 user#y.y.y.y -Nf
Works fine
or
ssh -L 3307:z.z.z.z:3306 user#y.y.y.y -Nf
To only bind to x.x.x.x's localhost
The first example binds to all interfaces
edit...
Just seen that z.z.z.z only has port 22 open.
on y.y.y.y you will also need to have a local port open
run on y.y.y.y
ssh -L 3307:localhost:3306 user#z.z.z.z -Nf
then on x.x.x.x
ssh -L 3307:localhost:3307 user#y.y.y.y -Nf
run these commands in a screen for best results
You can actually condense these 2 commands together
ssh -L 3307:localhost:3307 user#y.y.y.y -f 'ssh -L 3307:localhost:3306 user#z.z.z.z -Nf'
ssh -L <local-port-to-listen>:<remote-host>:<remote-port>
The āLā switch indicates that a local port forward is need to be created
Best method is to create the tunnel using putty (ssh client). so you can start the shell, and it will create the ssh tunnel for you. this is a good reference
https://howto.ccs.neu.edu/howto/windows/ssh-port-tunneling-with-putty/