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.
Related
I have a ssh server on an old CentOS 5 installation. I can connect to the server without any problems. However, if i disconnect from the server and want to login again after exiting the previous session, the server is not responding and i got a "connection timed out" error. After a while (must be between 1 and 5 minutes) i can login normally. If i then exit the session, the same timeout happens again.
From the network where the client resides, i can connect to other ssh servers without any problems, so i dont think, this is a firewall issue.
Any suggestions, where i can look for the problem?
I tried to login with key instead of password and i stopped the fail2ban service on the ssh server. Both without any success.
I solved my problem:
There is a iptables rule, which is limiting the connections per ip to one attempt per minute. I have whitelisted my ip and now there is no delay when reconnecting.
Context:
We have a VPS set up to which we connect through SSH (private keys auth, passwords forbidden, Fail2Ban running).
Recently we've been experiencing issues with the connection when we'd be kicked out (broken pipe) and re-connection attempts would end up with the "Connection closed by remote host" error. After several minutes of "down time" we could connect back as usual. During this time, communication on all other ports is dead as well (AApanel, WebApp ports).
Another thing to mention is that we can verify from VNS that during this down time the server is running and SSH ports are listening as if nothing happened (through lsof).
last command doesn't show any suspicious logins.
The problems persist even after a clean VPS re-install.
Any suggestion what these symptoms might be caused by?
Thanks
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).
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!
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.