Mobaxterm: how to prevent ssh session from exiting? - mobaxterm

How do i stop this?
Session stopped
- Press <return> to exit tab
- Press R to restart session
- Press S to save terminal output to file
Network error: Software caused connection abort
It looks SSH keepalive setting has no effect there

If you are still looking for the answer like me, here you go!
Settings -> Configuration -> SSH -> SSH keepalive
Restart MobaXTerm after changing the setting for it to take effect.
https://superuser.com/a/1298536

In my case I have SSH keepalive option checked but this happens every now and then.
So what I do is.
Disable (uncheck) SSH keeaplive close MobaXterm
Open MobaXterm and check SSH keeaplive close MobaXterm (again)
Open MobaXterm enjoy the stability for a couple of weeks...
I am using a licensed version on a computer running Windows 10 Professinal version 20H2.

Both solutions posted above (by #helloworld & #jepachecoh) actually work but there may be need for extra work, so here are a few additions.
The two options above work if:
1. You're connecting to a host (destination server) that is running SSH (daemon) but doesn't have any session timeout configurations set for connecting SSH clients.
2. You're connecting to a host that already has SSH client timeout configuration set but the set value (on the remote host) is either higher than, or equal to the "keepalive" value you have set on your SSH client (like MobaXterm, Putty etc).
If the destination server's "SSH keepalive configurations for the clients" are set, they override your remote client SSH keepalive configurations, hence controlling the session timeouts.
To find out if there are any configs set on the destination server's SSH configurations, use the command below (as root, or a user with sudo privileges):
$ cat /etc/ssh/sshd_config | grep "ClientAlive"
The command above works on multiple Linux and Solaris flavours.
If you don't have admin access to the destination server, your Systems administrator may be managing your session timeouts irrespective of the "keepalive" parameters you set on your SSH client before connecting.
Lastly, if you are using VPN software, or connecting to a demilitarized zone (DMZ), sometimes the session timeouts are controlled at that level (firewall level), so involve your Network administrator.
Bottom line, love your administrators. :-)

Related

2FA with VS Code Remote-SSH?

I am using the Remote-SSH extension in Visual Studio Code to connect to a remote machine. This remote machine is protected by Duo's two-factor authentication. When I SSH in a terminal (outside of VS Code), I'm able to log-in perfectly - the terminal prompts me through the 2FA process. However, inside VS Code when I'm using the extension, I am not able to log-in. After typing in my SSH hostname and ID, the VS Code interface prompts me for my password over and over again, and does not proceed beyond that point.
Has anyone encountered this issue before? I'd love to know if there is an existing solution. Unfortunately, 2FA is managed by my company and I can't turn it off.
I run into the same problem and fixed it by using SSH ControlMaster for Single Singe-On.
If you connect to the relevant machine using <user_name>#<host_name> you can simply add the following to your ~/.ssh/config:
Host <nickname>
User <user_name>
HostName <host_name>
ControlMaster auto
ControlPath ~/.ssh/%r#%h:%p
If you now open up a new session in your terminal running ssh <nickname> you will be asked for the password and the 2FA key. But all other subsequent ssh sessions (including svn, rsync, etc. that run over ssh) will piggyback off the initial connection without the need for re-authentication.
You can now in VS Code, select Remote-SSH: Connect to Host... from the Command Palette (F1, ⇧⌘P) and simply enter: <nickname> and ControlMaster will automatically connect you using the already standing connection.
In my case, the nickname that I choose is "ody". After connecting VSC's Remote Development extension shows the following in the bottom left corner and lets me browse the files on the remote machine.
From the FASCR:
Note that all subsequent connections are dependent on the initial connection — if you exit or kill the initial connection all other ones die, too. This can obviously be annoying if it happens accidentally. It’s easily avoided by setting up a master connection in the background:
ssh -CX -o ServerAliveInterval=30 -fN <nickname>
The -fN make it go into the background and sit idle, after authenticating. (C for compression,Y for X forwarding, and o ServerAliveInterval=30 to prevent dropped connections have nothing to do with the ControlMaster but are almost always helpful.)
Note that all port forwarding, including X display forwarding, must be setup by the initial connection and cannot be changed.
Got to settings in VS Code and enable this setting, remote.SSH.showLoginTerminal. This pulls up the terminal so that sign in via 2FA that way.
You can use ~/.ssh/config file to configure your hostnames and keys. But I don't know if there is a way to save passwords for convenience.

Emacs-Tramp: Not working properly

I'm trying to use Tramp/Emacs-23 in Ubuntu 12.04 in order to edit the remote host files. My remote host has two step authentication (RSA+Passwd). I use multiplexing through .ssh/config to ensure that tramp can directly connect to the remote shell without having to provide passwords.
My problem however is that I have 3 different remote hosts. When I try to connect to remote host through tramp without the initial multiplexing (through terminal), the TRAMP hangs with a message stating "Tramp: Waiting for prompts from remote shell". I used the below mentioned commands in .ssh/config to ensure the connection gets lost after a specified interval upon no prompt.
Host *
ServerAliveCountMax=30
ServerAliveInterval=5
However this doesn't seem to have any effect on the tramp connection. It will be of help if someone can help me in fixing this issue.
Sorry that your question has been left hanging so long.
I can offer a couple of things to try, use the tramp protocol sshx instead of ssh, it seems to cope better with most non-vanilla ssh connections.
e.g.
/sshx:user#host:path/filename
The other thing to try is adding your ssh key passphrase to the session at startup, run an ssh-agent on the machine, and connect to it at startup, then run ssh-add to enter the passphrase once.
As a side note, upgrade your Emacs to 24.3 there's a lot of new/great stuff in there since 23.x

NetBeans Remote Connection

I'm trying to set netBeans remote project and I'm having pretty much trouble with it. I've started a PHP Application from Remote Server and in the last confirmation step it throws error on me.
No files available for download. Try to check Passive mode in the remote configuration.
In the log output it fails there:
> 215 UNIX Type: L8
> PORT 192,168,5,217,196,73
> 500 Illegal PORT command.
Did anyone have same problem with setting up remote connection? Please help.
To establish an FTP connection, choose either of the options below:
Turn off the Windows firewall.
Configure Windows Firewall for a passive mode FTP server as follows:
Open an Administrator command-prompt.
Click Start > All Programs > Accessories.
Right-click Command Prompt, and then click Run as Administrator.
Run the following command:
netsh advfirewall firewall add rule name=FTPService action=allow service=ftpsvc protocol=TCP dir=in
Disable stateful FTP filtering so that the firewall does not block any FTP traffic:
netsh advfirewall set global StatefulFTP disable
This seems to be the top answer whenever anyone is looking for how to set netbeans into passive mode. Despite the advice always being "set the ftp into passive mode" for those using Mac OS and Netbeans you may never seem to find it.
Right click on the project
Select Properties
Select Run Configurations
Select Manage
Select your_ftp_connection on the left column
Scroll down
The only way I fixed this was to switch to using SFTP. This obviously requires that you've set up SFTP (FTP over SSH) access to your server.
In the Run Configuration, when it asks you for the Remote Connection:
Click on 'Manage'
Click on 'Add...'
Select SFTP as the connection type
Fill in the rest of the details as if it were a normal FTP connection.
Turning plain FTP Netbeans connection into passive mode solved the problem for me.
Please Check Passive Mode; i had faced the same issue; after checking it; resolve this issue.
There is no way to find the passive mode in a OSX. It's a Netbeans bug... So I won't be able to develop on netbeans using my Mac. Already tried to download last version.
For me the solution was to check Passive Mode on the client and to do following things on the server side
in /etc/vsftpd.conf
pasv_enable=Yes
pasv_max_port=10100
pasv_min_port=10090
then in terminal
iptables -I INPUT -p tcp --destination-port 10090:10100 -j ACCEPT
service iptables save
service vsftpd restart

Tramp mode in emacs using ssh config

I think this is very basic question in using tramp, but it doesn't work for me.
I have my ~/.ssh/config file that points to my amazon ec2 machine
Host amazon
Hostname xxxx.amazonaws.com
Port yyy
User me
IdentityFile ~/.ssh/ubuntu
ForwardAgent yes
I can easily do ssh amazon from my terminal and I go to amazon ec2 (so my config is right), but in emacs
I do:
C-x C-f /ssh1:amazon:
I always get this error
In Aquamacs:
Process *tramp/ssh1 amz* exited abnormally with code 255
In Emacs:
tramp: Opening connection at amz using ssh1...
tramp: Waiting for prompts from remote shell
tramp: Waiting 60s for prompt from remote shell
tramp-process-actions: Login failed
I also have other ssh configurations that they ssh to my virtual boxes on my local machine and they have the same problem.
I really appreciate any help.
One thing that's worth trying is using the sshx connection method. That makes tramp try to avoid any non-standard shell configuration on the remote host.
Like this:
C-x C-f /sshx:amazon:
The tramp method ssh1 forces ssh to be run in ssh v1 protocol mode with the parameter -1. ssh v1 has known weaknesses and is insecure. Hence a lot of sites disable the ssh v1 protocol.
You can verify this from the shell with ssh -1 me#xxxx.amazonaws.com.
Try other tramp connection methods like ssh, sftp or scpx. You can see all pre-configured connection methods with C-h v tramp-methods.
If Moritz Bunkus's answer doesn't solve the issue, then you can configure the verbosity of tramp's output with
M-x customize-variable RET tramp-verbose RET
In particular, level 6 is "sent and received strings" which might help you to determine whether the "Waiting for prompts from remote shell" is because it isn't receiving a prompt pattern that it recognises, or because of some more critical failure.
If it's simply receiving a prompt it doesn't recognise, then you might look at customizing the tramp-login-prompt-regexp or tramp-shell-prompt-pattern variables.
(Of course if your ssh agent is working correctly, then login prompts shouldn't be relevant.)
If you're running Emacs in Windows, then also see these Q&As:
Emacs: Tramp doesn't work
Using tramp with EmacsW32 and cygwin, possible?

How to set nodejs debug mode don't listen 127.0.0.1

I want to remote debug the nodejs program in Eclipse. I start the node script with the debug option.
$node debug script.js
But I can't connect to the node in Eclispe. When I netstat the node's TCP port. I found that node only listen 127.0.0.1 in debug mode. So I can't connect it from different computer.
But I can't find any startup options that can change to listen to any address.
Anyone know to make it listen to any address to remote debug in other computer?
if anyone else stumble upon this: you can set the node debug to any address as you set the port
node --debug=169.168.1.2:5858 app.js
if that would be the ip of your remote machine or even better to every machine
node --debug=0.0.0.0:5858 app.js
but please be aware that the 2nd option should only be used if you are debugging in your own private network as you open it up for everyone
This is what I do in linux Debian:
install balancer
sudo apt-get install balance -y
then create a route in balancer to reroute your 5858 port to 5859
balance 5859 127.0.0.1:5858
start your app
node --debug app.js
now you can access it from everywhere on port 5859
I'm looking into V8 code that goes through deps/v8/src/debug-agent.* down to deps/v8/src/platform-posix.cpp (for linux) to POSIXSocket::Bind method and it can't seem to have any option about this (unless I'm missing something).
I bet you either hack it and recompile node or you'll need to build a small proxy beside your node process.
Here's a great tut on debugging nodejs from eclipse. Note at the bottom there is a script the author uses to forward localhost:5858 to the remote server's 127.0.0.1. You could also just use an SSH tunnel.
So, to summarize:
start your script with node --debug app.js
configure eclipse as if you were debugging locally
use the node_g script or configure an SSH tunnel
go on vacation now that your code is bug-free
to debug nodejs remotely over SSH session do:
1. install balance on Linux: https://balance.inlab.net/overview/
2. run the command: balance -df 8585 127.0.0.1:5858 > /tmp/balance.out 2>&1 &
3. ssh to your remote Linux box (tunnel will be created 8585 > 5858 > nodejs)
4. run your node script on server: node --debug-brk --nolazy ./myNodeApp.js
5. kick off debug session in WebStorm alt-d to port 8585
now you are remote debugging securely over SSH session