Mobaxterm: how to keep sftp connection alive? - ssh

I kept ssh connection alive following this post:
Mobaxterm: how to prevent ssh session from exiting?
I managed to keep ssh connection alive but sftp connection on the left panel keeps disconnecting after a certain time while ssh is still alive and I have to every time reconnect the sftp. Sometimes, reconnect button on the left panel doesn't even work and I have to exit the shell and restart the ssh session again. What I want to achieve here is to keep the sftp connection (graphical browser on the left panel) alive in addition to ssh. Thanks.

I have the same problem, then I asked MobaXterm support and they gave me this answer:
You should update the SSH browser type to "SCP enhanced speed" mode. For this you can go to the settings of your SSH session, go to the advanced SSH settings and in the SSH browser type drop list choose SCP (enhanced speed).

Related

How properly set up remote server through nested tmux sessions

I'm trying to set up my remote server so that I can ssh in, start a python process, then detach, logout, and shut down my local computer. I've been able to do this before using nested tmux sessions:
local host - tmux - ssh into remote
remote host - tmux - start python process - detach remote tmux
"exit" from the remote host and close down the remote session.
This was working just fine for me. I can detach the remote session, close down ssh, shut down everything locally, then boot up, relogin via ssh, and then reattach the remote tmux session.
My issue is that now my remote server is in a lab setting (I now run a lab with multiple people, whereas before it was just me). I don't want different users to be logging in when there is a process running. I'm trying to limit people not knowing a server is in use, logging in to start a process, and disrupting (or diverting memory from) a process being run by another user.
My way around this was to setup a generic login user and password that everyone in the lab uses. Then, for that generic user, I edited the /etc/security/limits.conf file to have a maxlogins of 1 for that user. While this works in practice (no other user can log in when one is already logged in), it means I can no longer RE login.
Now I get:
local host -> tmux -> ssh into remote
remote host -> tmux -> start python process -> remote detach
remote host -> exit ssh
local host -> tmux -> ssh into remote:
Too many logins for 'lab2'.
It appears that, with the process still running, the login stays active and I am trying to 'relogin' to an ongoing login session. But since I've set the max to 1, I cannot. Does anyone have any advice for how to fix this?
Thanks!

Prevent sshfs reconnecting

I use sshfs to connect to a remote server. When my computer goes to sleep or internet drops, sshfs tries to reconnect when the connection comes back, but does not ask me for a password. Because of this, the reconnect fails, and after several attempts my IP address is blocked indefinitely from connecting to the server (until I convince them to unblock me). Overall this is completely untenable. How can I prevent sshfs from reconnecting? I am not using any of the ServerAliveInterval, ServerAliveCountMax, or -o reconnect options.

Start ssh in background on OpenWRT via ssh

Good morning,
I recently moved to the universities dormitory and they have a specific way how to enable the internet connection. They require me to connect to the network via Cable, set up a specific static IP and then enable the Internet connectivity by ssh'ing to a special IP with my own account and password. As long as this ssh session is open, the internet connection is active. If closed, then it is lost.
My setup right now is like this: I connected an OpenWRT-based TP-Link router (TP-Link TL-WR841N/ND v9) to the dormitory's network. My devices are connected to the router's wifi.
To get an internet connection, right now I am doing this:
connect to the router via ssh
connect to the internet via ssh on the router
So basically I am having two running ssh sessions. This is quite annoying as my laptop has to be on and running if I want to have an internet connection. My idea would be to keep the ssh session on the router running all the time. For this, however, I would need to keep the ssh session running in the background of the router.
Starting the second SSH with & skips the password entry. So I have to get it back to fg, enter the password and the process is back in the foreground. CTRL+Z appears to be not working on OpenWRT.
The only thing which could skip the password entry would be connecting with a key, but the server I am connecting to is not allowing that.
Anybody having other ideas?
You can do multiple things to solve this
Create a script(which will connect to internet) in router and schedule it in a cron job
If nohup/tmux is available in the router, execute the commands with them so that they keep alive when the ssh session is terminated.
So, looks like I solved the problem.
As nohup/tmux is not available on the router, I had to find an equivalent. Fortunately, screen is available for my router. With screen, you can start the ssh for the internet in a separate screen. When it's running, you can simply detach the screen and close the ssh to the router.
The ssh-connection for the internet will continue running in the background of the router.
The only drawback is that I have to reconnect manually, as soon as the router restarts.

SSH Google Compute Engine down?

There's an issue with SSH access today ? Don't know why I can't access to my instances today, from a MobaXterm or the SSH webinterface in Google Cloud (impossible to connect port 22).
From Google Cloud Shell => ssh: connect to host XXXX port 22: Connection timed out
Global issue or only my account ?
I would advise you to try the following and check if you are able to connect:
Can you able to ping or SSH into VM instance using gcloud command ?
Could you also try running cloud shell in safe mode.
If you are still running the issue after trying 2 methods, please try to restart the cloud shell (This can be done by selecting restart option from hamburger menu on top right of your Cloud shell) and see if that fixes.
You can interact with the serial console so you can more easily troubleshoot instances that are not booting properly or that are otherwise inaccessible.
Please let me know of the results.

Amazon EC2 ssh timeout due inactivity

I am able to issue commands to my EC2 instances via SSH and these commands logs answers which I'm supposed to keep watching for a long time. The bad thing is that SSH command is closed after some time due to my inactivity and I'm no longer able to see what's going on with my instances.
How can I disable/increase timeout in Amazon Linux machines?
The error looks like this:
Read from remote host ec2-50-17-48-222.compute-1.amazonaws.com: Connection reset by peer
You can set a keep alive option in your ~/.ssh/config file on your computer's home dir:
ServerAliveInterval 50
Amazon AWS usually drops your connection after only 60 seconds of inactivity, so this option will ping the server every 50 seconds and keep you connected indefinitely.
Assuming your Amazon EC2 instance is running Linux (and the very likely case that you are using SSH-2, not 1), the following should work pretty handily:
Remote into your EC2 instance.
ssh -i <YOUR_PRIVATE_KEY_FILE>.pem <INTERNET_ADDRESS_OF_YOUR_INSTANCE>
Add a "client-alive" directive to the instance's SSH-server configuration file.
echo 'ClientAliveInterval 60' | sudo tee --append /etc/ssh/sshd_config
Restart or reload the SSH server, for it to recognize the configuration change.
The command for that on Ubuntu Linux would be..
sudo service ssh restart
On any other Linux, though, the following is probably correct..
sudo service sshd restart
Disconnect.
logout
The next time you SSH into that EC2 instance, those super-annoying frequent connection freezes/timeouts/drops should hopefully be gone.
This is also helps with Google Compute Engine instances, which come with similarly annoying default settings.
Warning: Do note that TCPKeepAlive settings (which also exist) are subtly, yet distinctly different from the ClientAlive settings that I propose above, and that changing TCPKeepAlive settings from the default may actually hurt your situation rather than help.
More info here: http://man.openbsd.org/?query=sshd_config
Consider using screen or byobu and the problem will likely go away. What's more, even if the connection is lost, you can reconnect and restore access to the same terminal screen you had before, via screen -r or byobu -r.
byobu is an enhancement for screen, and has a wonderful set of options, such as an estimate of EC2 costs.
I know for Putty you can utilize a keepalive setting so it will send some activity packet every so often as to not go "idle" or "stale"
http://the.earth.li/~sgtatham/putty/0.55/htmldoc/Chapter4.html#S4.13.4
If you are using other client let me know.
You can use Mobaxterm, free tabbed SSH terminal with below settings-
Settings -> Configuration -> SSH -> SSH keepalive
remember to restart Mobaxterm app after changing the setting.
I have a 10+ custom AMIs all based on Amazon Linux AMIs and I've never run into any timeout issues due to inactivity on a SSH connection. I've had connections stay open more than 24 hrs, without running a single command. I don't think there are any timeouts built into the Amazon Linux AMIs.