Get access to specific terminal emulator over SSH - ssh

background:
I use a linux box(call it host) everyday. But sometimes, the GUI/mouse/keyboard stop working and it(host) hangs. I was not able to do anything but restart it(host). So, now i always a ssh server running on it(host) so that I can connect to it and turn off things safely. I do this by using VNC client on my laptop(call it REMOTE). It replicates the whole screen from the host, so even if my mouse/keyboard on the host don't work, i could close things with REMOTE. But VNC is expensive on network usage and slow. I want to replace it with normal ssh connection.
problem redefined:
So, if I start a simple program to print "hello world" endlessly on terminal on the "host". How can i see the same terminal(with hello world printing) on "REMOTE" over SSH. Not just see, control this program say stop it, kill it etc.

Related

Pycharm cannot finish updating skeletons

I'm newly moving from a Linux working environment to Windows, and I'm mainly using local port forwarding+Pycharm to run my python code on a server that is double-hop from my laptop.
I am able to establish the ssh tunnel through Windows cmd or MobaXterm local terminal or MobaXterm tunneling tool. I works fine on my Pycharm, when I check it from tools/deployment/configuration/test connection, and I can also see the files in remote server. But every time I start my Pycharm, it shows two background process, "updating python interpreter" and "updating pycharm helper", and the precess bar simply do not show any moving on! And I cannot run python on remote server, because Pycharm says I lack python helper.
And most wired, when it is running these two precess, my terminal for local port forwarding freezes, and I cannot type in commands in the jump server. And when I try to recheck the connection, it turns out that connection fails.
My ssh tunneling+pycharm deployment used to work fine in my Ubuntu. Thanks anybody who can shed light on my confusion!
Well, thanks everyone, I have solved this problem.
The reason is simple, but I did not notice that the ~/.pycharm_helper 's size is actually changing in the process, while the GUI bar may be not moving.
So it is due to my double-hop inconvenience, and the low Internet speed. I left it in dorm for a whole night out, and it comes out just fine.

Google Compute Engine instance restarts when I ssh

I have a deep learning vm setup on google cloud platform. I ssh into by clicking the ssh button in my list of vm instances. The problem I am having is that if I run a program and close the ssh window while it is still running, when I ssh back into the vm, the program has been interrupted and the whole vm essentially has restarted.
Is there a way to setup my vm so that I can run a program and then close the ssh connection without it restarting the vm? I want to be able to run programs without being required to leave the ssh window open and my computer on.
As #Rup pointed out, processes belonging to your SSH session's shell will get a hang-up signal when you close the connection. To bypass the hang-up signal and let a program continue running, use the nohup command. Here is an example
nohup python test.py &
That will run the program test.py and as well as ignore the hang-up signal. The programs output will be stored in a nohup.out file.

SSH from one computer, continue on another?

I have a home server running Ubuntu Server 14.04 and I've setup OpenSSH on it. But. I'm intending to run some terminal based stuff that takes long time to be finished.
So what I wanna be able to do is ssh into the server, start the process, log out of the computer i connected with and connect from another device and have that process I started still running.
Almost like a remote-desktop type SSH connection.
If this is not possible then I'll just install a desktop environment and vnc server.
Try nohup & command.
This way the shell should keep the process running, even if you log out.
One option is the program tmux or screen, which you can detach from and log out.
Instructions for tmux:
$ ssh me#server
$ tmux
run commands
Ctrl-B d (this
means push CTRL-B then push d to detach from tmux) logout
If you want to see the results, use tmux attach when you log back in. Your session will be exactly as you left it.

Remote interaction via VNC+Expect?

I've being doing a installation process in several machines in virtualbox and I'd like to try automated this process. I can do a expect script (see below), however I can't connect through ssh because this script will configure the network stuff after some other processes.
Where I work now, we use the vmware esxi and I am trying to discover if it's possible to automated the installation process that I said if I setup the vnc viewer in the guest machine. I can do the all process if I do it manually, but I'd like try to automated it. Although I think a expect script will be fine, I'm not connecting by ssh. Is it possible?? I started to think that maybe expect is not my answer here.
The processes is something like this:
Receives "Choose a option: ", sends "1\n"
Receives "Press any key", sends "\n"
Repeat step 2 more two times.
Receives "Do you agree (y/n)?", sends "y\n"
And so on.
The host as I said is a vmware esxi, the guest is similar to a linux and my machine is a fedora 20 (I'm saying this because I dont like the idea of install stuff on esxi).

How to exectute a Mathematica Script through ssh

here is my problem: i would like to run a Mathematica script through ssh on a remote machine so that i can close the terminal on my computer and keep it running on the remote one.
My problem arises because the script acts in interacting mode, and so when i close the terminal the process is shut down too.
Thanks.
Use tmux or GNU screen.
Workflow:
ssh into remote machine
start tmux/screen, e.g. tmux or screen
start Mathematica script inside tmux/screen session
detach tmux/screen session, e.g. Ctrl+B d (tmux) or Ctrl+A d (screen)
close ssh connection
Then later:
ssh into remote machine
reattach to tmux/screen session, e.g. tmux attach or screen -d -R
view completed Mathematica script output
Several cases:
If you don't need to interact with it or need to visualize the notebook during evaluation
Log in to the machine with ssh
Then, to run a kernel in the background and detach it from the current session, use nohup tool (the standard output of the command will be dumped to myNotebook.out):
nohup math < myNotebook.nb > myNotebook.out &
At this point, the ssh session can be closed without killing Mathematica
Optionally you can monitor mathcommand output with the tail command (use CTRL-C to exit the tail monitoring)
tail -f myNotebook.out
If you need to see what's going on, visualize graphs during calculation or to be able to interact graphically, use remote desktop (vnc) and tunnel your communication with remote machine. Details depends a bit on the Linux distribution (vnc clients & servers may differ). You can even from Windows or Mac connect with remote desktop to your linux box and manipulate it. I suggest you to search the web for remote desktop ssh tunnel + your distro for tutorials.