how to set tuneling on mobaXterm homescreen? - ssh

To run a job on remote server of my uni, I use MobaXterm.
First I had to "start local terminal" and type "ssh somenet.mylab.uni.ac.bla – username:BlaBla" (the address is fake). Type a password, and connect. Next, I had to type "ssh login8" and I on the server I can submit my jobs.
Now, on the home Screen of MobaXterm I can select the last session and it connects (ssh) to "somenet.mylab" with no problem, but not to the next server (login8).
How Can I add the next server to the "home screen" without typing each time "ssh login8"? I tried the "tunneling" option in the upper panel, and added "New SSH tunnel", but it seem to have no effect.

Related

How to open Apache Airflow, using SSH in Putty in web, when port 8080 is already taken by Postgres?

I have a cluster running on Google Cloud. I have an active connection to master, using Putty SSH (I have used public and private keys generated by PuTTy Key Generator), so I am logged in as a user and I have a password. At the same time, I have Apache Airflow server running in master (I run it by using SSH in Google Cloud).
I want to see graphical interface and graph flow at port 8080. However, it is already taken.
enter image description here
enter image description here
I have typed in cmd the following command: netstat -a -n -o | find "8080"
The result is like that:
enter image description here
I've tried stopping what is running on this port but I can't do it.
What should I type in "Source port" and "Destination" in Putty SSH Tunnels configuration to open Apache Airflow?

PyCharm "Failed to connect to" SSH server with proxyjump

I'm struggling to connect PyCharm to a remote SSH server.
In my Linux command line, I can connect to the server by ssh t400-208n5 and write my password easily. But it seems PyCharm can't!
I have the .ssh/config file like this:
Host merkur
Hostname "server"
User zahra
Port 22
IdentityFile ~/.ssh/merkurKey
Host t400-208n5
Hostname "server"
User zahra
IdentityFile ~/.ssh/merkurKey
ProxyJump merkur
Then I config PyCharm like the photo below. Everything looks right.
But when I press next and after submitting my password I get Failed to connect to zahra#t400-208n5:22. I don't know what is wrong any help would be appreciated.
Some further information if it is useful.
As you can see in the picture above, despite the error I can still click on the next button, so I did.
To my surprise, it gets connected to the server after that but not completely! I can see all of the files by opening the Remote Host section. And by going to Tools > Start SSH session... I can connect to the server and I did run htop successfully. So it seems it is connected.
BUT I can't run any code. Running a file like temp.py will error in /usr/bin/python3.9: can't open file '/tmp/NlMO0vICFC/temp.py': [Errno 2] No such file or directory and I don't know what is that NlMO0vICFC in the path!
The other thing is my development box is all gray which means it is not set up and does not work.
And another thing that may be useful is the difference between this and my previous SSH connections. In my previous SSH connections before next to the name of the connection "agent" was written but now "password" is written. Here is a photo of it.

Trying to access remote jupyter notebook via ssh tunnel

I need some help accessing a remote jupyter notebook instance
normally, when I am trying to access a jupyter notebook running on a remote server on my mac, I will write the following in a terminal window to create the tunnel
ssh -NL $local_port_number:localhost:$remote_port_number $my_username#$remote_server
afterwards, I can usually access the jupyter server at http://localhost:local_port_number
how do I do this in putty on windows? I know there is some option in connection>>ssh>>tunnels to do this, but I cannot get the configuration to work so far.
In remote host, open the terminal, change directory to where you have your notebooks and type:
jupyter notebook --no-browser --port=8889
# you should leave the this open
In your local computer, open MS-DOS cmd (if using Windows) or Unix terminal, then type:
ssh -N -f -L localhost:8888:localhost:8889 username#your_remote_host_name
# make sure to change `username` to your real username in remote host
# change `your_remote_host_name` to your address of your working station
# Example: ssh -N -f -L localhost:8888:localhost:8889 laura#cs.rutgers.edu
Now open web browser (google chrome, firefox, ...) and type:
localhost:8888
# you will see your notebooks in your given directory
From:
http://amber-md.github.io/pytraj/latest/tutorials/remote_jupyter_notebook
To access Jupyter over the SSH tunnel on Windows you will need to 1) initiate the tunnel in Putty and 2) configure your web browser to send traffic over the tunnel.
To Initiate the tunnel in Putty:
1) Navigate to Connection-->SSH-->Tunnels
2) Put in the local address for which you want to forward traffic
3) Click the 'Dynamic' radio button
4) Click the 'Add' button
5) Click the 'Open' button to initiate the connection
For Chrome and Internet Explorer
1) Use the Start->Run menu to run inetcpl.cpl
2) In the 'Connections' tab click 'LAN Settings'
3) Click on the 'Use a proxy server for your LAN' check box
4) Click 'Advanced'
5) In the 'Socks' field type '127.0.0.1' and add the port that you chose above
6) Apply these changes by clicking the 'Ok' button
You should now be able to access Jupyter over the SSH tunnel.

How to do other "stuff" in the same terminal where you establish an SSH tunnel

I often use an ssh tunnel. I open up one terminal to create the tunnel (e.g. ssh -L 1111:servera:2222 user#serverb). Then I open a new terminal to do my work. Is there a way to establish the tunnel in a terminal and somehow put it in the background so I don't need to open up a new terminal? I tried putting "&" at the end, but that didn't do the trick. The tunnel went into the background before I could enter the password. Then I did fg, entered the password and I was stuck in the ssh session.
I know one possible solution would be to use screen or tmux or something like that. Is there a simple solution I'm missing?
There is the -f and -N options exactly for that:
-f Requests ssh to go to background just before command execution. This is useful if
ssh is going to ask for passwords or passphrases, but the user wants it in the
background. This implies -n. The recommended way to start X11 programs at a remote
site is with something like ssh -f host xterm.
If the ExitOnForwardFailure configuration option is set to ``yes'', then a client
started with -f will wait for all remote port forwards to be successfully established
before placing itself in the background.
-N Do not execute a remote command. This is useful for just forwarding ports
(protocol version 2 only).
So the full command would be ssh -fNL 1111:servera:2222 user#serverb.
A way to prevent ssh asking for the password would also be to use SSH public keys for authentication with an agent that either saves the password or prompts it using an external graphical program such as pinentry.
It might also be useful for you to look into autossh, which will reconnect your SSH automatically if the connection drops.

start ssh-agent in remote ssh session

I connect to a server that runs xubuntu and start ssh-agent there. Then I execute ssh-add on the remote server and run rysnc commands that would require to enter the passwort mutliple times.
With my solution I only have to enter it one time. But how can I start the ssh-agent permanentely? I want to reuse it over multiple ssh sessions.
My solution so far:
ssh myhost 'eval $(ssh-agent); ssh-add;'
You can use agent-forwarding in ssh: -A switch. Basically, it will create the agent on your host and when you connect to myhost, you will have your agent in all your sessions and you will not be prompted for password again.
Basically agent should be started automatically with your session, so all you need to do is to add your keys locally and then connect to remote hosts with -A switch.
It is impossible to have running ssh-agent permanently, since it is running under your session. Basically if you don't close the first session, there is some way to connect to it, but it is certainly not the thing you want to do