LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-23-2020, 04:35 AM   #1
SegFault1
LQ Newbie
 
Registered: Jul 2018
Distribution: Void Linux
Posts: 23

Rep: Reputation: Disabled
Please suggest a workflow for working on a remote machine.


My organization has a very powerful machine that I use to run my ML models. It runs on some version of Ubuntu. Due to this ongoing pandemic, I have to work from home. This machine is not public facing and therefore, I VPN into my organization network using OpenFortiVPN. And then I SSH into that machine.

The problem is that my internet is not very good and/because it a mobile network that I tether on my machine (and that's why I get a dynamic IP evertime I am connected to the network). However, that machine at my organization is connected to very good network. The datasets that I work with are hundreds of GBs. I cannot download the dataset and work on my machine. The dataset and computing power reside on the remote machine, not on my machine.

Suggest a workflow for this setup. The problems I face are,
  • When I SSH into the machine, I only get one terminal. I need many terminal---to edit my code for the model, to run my model, to examine datasets, etc. I don't want to exit my editor every time I want to AWK into my dataset or, run my code. The models take a lot of time to train and run, I don't want to sit and look at my cursor, I'd rather look at my code. I can finally turn to TMUX or Screen, but I want to keep them as a last resort.
  • My dataset also contains images, and while examining dataset, I sometimes need GNUPLOT. SSHing into the machine doesn't give me a X.
  • I tried mounting the remote machine using SSHFS to my local machine. That solves some problem, but now my local machine becomes slow due to a slow connection to the remote machine. And viewing images on that mountpoint downloads the entire directory which my network cannot support.
  • Due to my choppy internet, that key press has a noticeable lag in the SSH session. As someone who doesn't even use a DE (only tiling-WMs or sometimes even without X) to work fast, this lag gets on my nerve.
  • I don't know why, but if I leave my SSH terminal for too long without activity, the terminal hangs. Maybe due to bad connection, but not sure.

Please don't suggest me Jupyter (or alike) as I like to work in a terminal with my own editor (that has been vimrc-ed to hell) and also, my python scripts are dependencies everywhere that Jupyter doesn't handle well. I need my bare bones python.

Admittedly, I'm new to SSH, and VPNs and networking so, if there is something obvious that I'm missing in my setup, please tell me.
 
Old 07-23-2020, 04:41 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,982

Rep: Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337
without GUI the best you can do is tmux or screen or something similar.
ssh can be used with -X (or -Y) if you wish to use GUI. But probably not the best solution for you.
You can try VNC to have a local display somewhere and you will only connect to that display (or actually you can try any other remote desktop solution).

We cannot help on the lagging, that should be solved by (or inside) your company and ISP.
 
Old 07-23-2020, 05:02 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,335
Blog Entries: 3

Rep: Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731
Quote:
Originally Posted by SegFault1 View Post
  • When I SSH into the machine, I only get one terminal. I need many terminal---to edit my code for the model, to run my model, to examine datasets, etc. I don't want to exit my editor every time I want to AWK into my dataset or, run my code. The models take a lot of time to train and run, I don't want to sit and look at my cursor, I'd rather look at my code. I can finally turn to TMUX or Screen, but I want to keep them as a last resort.
  • My dataset also contains images, and while examining dataset, I sometimes need GNUPLOT. SSHing into the machine doesn't give me a X.
I'm quite a fan of tmux and would encourage getting comfortable with it. With even just a few basic activities scripted or commited to memory, it becomes very, very useful. It can even be launched with pre-defined windows and panes, and programs within those panes, if you need that.

You can also reconnect SSH and tmux automatically if you are authenticating to the remote machine with keys or certificates. Here is an example of reconnecting automatically using a key and from there reconnecting to an existing tmux session named 'models' or create it if it does not already exist.

Code:
ssh-add ~/.ssh/somekey;
while ! ssh -i ~/.ssh/somekey segfault@xx.yy.zz.aa \
    'tmux attach-session -t models -d || tmux new-session -s models'; 
do 
        sleep 2;
done;
You can also put quite a bit into the SSH client's configuration file, ~/.ssh/config, as far as keys and user names go.

Code:
Host model2
        Hostname model.example.com
        User segfault1
        IdentitiesOnly yes
        IdentityFile ~/.ssh/somekey
        ForwardX11 yes
        RemoteCommand tmux a || tmux 

Host *.example.com
        ServerAliveCountMax 3
        ServerAliveInterval 30
That would give you a shortcut 'ssh model2' for those settings.

Code:
while ! ssh model2; 
do
       sleep 2;
done;
See "man ssh_config" for the details.

If you need to run a graphical program on the remote host yet have it displayed locally, throw in -X to the above formula. However, there can be a bit of lag when working interactively that way.
 
Old 07-23-2020, 05:15 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,982

Rep: Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337
Oh yes, TurboCapitalist already explained, here is a possible solution to the timeout (last point): https://patrickmn.com/aside/how-to-k...-ssh-sessions/
 
1 members found this post helpful.
Old 07-23-2020, 05:20 AM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,763

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
ssh does have an idle time out and will automatically disconnect but looks like it just hangs. You can adjust some settings in the ssh_config file as posted

As posted tmux or screen are your only options with out a GUI. Any remote desktop would likely increase bandwidth needs and increase lagging. Your only solution is to get a better personal network connection if possible.

Last edited by michaelk; 07-23-2020 at 05:28 AM.
 
1 members found this post helpful.
Old 07-23-2020, 05:22 AM   #6
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,335
Blog Entries: 3

Rep: Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731
(Oops. I am slow in typing. )

Quote:
Originally Posted by pan64 View Post
Oh yes, TurboCapitalist already explained, here is a possible solution to the timeout (last point): https://patrickmn.com/aside/how-to-k...-ssh-sessions/
Useful link, as it covers the server side too.

Quote:
Originally Posted by SegFault1 View Post
  • Due to my choppy internet, that key press has a noticeable lag in the SSH session. As someone who doesn't even use a DE (only tiling-WMs or sometimes even without X) to work fast, this lag gets on my nerve.
  • I don't know why, but if I leave my SSH terminal for too long without activity, the terminal hangs. Maybe due to bad connection, but not sure.
The lag is probably due to the VPN. If it can be removed and the inner machine accessed via an SSH jump host instead, it would be more secure (according to the cipher choices at least) and faster with less latency.

You could then connect to the inner machine via the jump host using the ProxyJump option.

Code:
ssh -J jump.example.com model.example.com
Some call it a bastion host.

As for the connection dropping, that too might be the VPN. If you have the SSH client send both a TCP and SSH heartbeat maybe that will help as mentioned. From the tail end of ~/.ssh/config

Code:
Host *.example.com
        ServerAliveCountMax 3
        ServerAliveInterval 30

Host * 
        TCPKeepAlive yes
 
Old 07-23-2020, 05:24 AM   #7
SegFault1
LQ Newbie
 
Registered: Jul 2018
Distribution: Void Linux
Posts: 23

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Turbocapitalist View Post
I'm quite a fan of tmux and would encourage getting comfortable with it. With even just a few basic activities scripted or commited to memory, it becomes very, very useful. It can even be launched with pre-defined windows and panes, and programs within those panes, if you need that.
This is interesting. I've tried tmux before but didn't stick to it since AwesomeWM+tmux felt redundant. And while working with tmux, my AwesomeWM's muscle memory kicks in and instead of moving around in different panes, I do something weird. Also, CTRL+B (like the ESC counterpart of Vi) is a bit weird, I tried to map it to backslash, but it didn't work for some reason. And copying text in tmux is weird since, it copies pane borders and text from other panes. If you can point me to a link that fixes these problems, that'd be great. Thank you.
 
Old 07-23-2020, 05:53 AM   #8
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,335
Blog Entries: 3

Rep: Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731
Changing the prefix key is easy. Here it is changed to ctrl-backslash, but it could be set to anything else just as well:

Code:
tmux set -g prefix C-\\
tmux unbind-key C-b
tmux bind-key C-\\ send-prefix
The mouse is a more challenging problem since the mouse is on the local machine and the tmux session is on the remote machine. If you connect to the remote machine using X11 forwarding using the -X option and have xclip installed there as well, then the following formula for .tmux.conf works:

Code:
set -g mouse on
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"bind -n WheelDownPane select-pane -t= \; send-keys -M
bind -n C-WheelUpPane select-pane -t= \; copy-mode -e \; send-keys -M
bind -T copy-mode-vi    C-WheelUpPane   send-keys -X halfpage-up
bind -T copy-mode-vi    C-WheelDownPane send-keys -X halfpage-down
bind -T copy-mode-emacs C-WheelUpPane   send-keys -X halfpage-up
bind -T copy-mode-emacs C-WheelDownPane send-keys -X halfpage-down

# To copy, left click and drag to highlight text in yellow,
# once you release left click yellow text will disappear and will automatically be available in clibboard                                                       # # Use vim keybindings in copy mode
setw -g mode-keys vi
# Update default binding of `Enter` to also use copy-pipe
unbind -T copy-mode-vi Enter
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -selection c"                                                                           bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"
from https://unix.stackexchange.com/quest...ouse-with-tmux

Then you can highligh the text, press Enter, and it will be in the local machine's clipboard.

Remember that Enter and Return are not the same.
 
1 members found this post helpful.
Old 07-23-2020, 06:16 AM   #9
SegFault1
LQ Newbie
 
Registered: Jul 2018
Distribution: Void Linux
Posts: 23

Original Poster
Rep: Reputation: Disabled
Thank you, Turbocapitalist for taking time to help me and showing around. Guess its time to read man pages.
 
  


Reply

Tags
remote session, ssh



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Rsync files from a remote machine into another remote machine (Indirectly) sparkling Linux - Newbie 1 04-27-2017 11:36 AM
how to know the remote machine is Virtual machine or physical machine pantdk Linux - Server 19 10-16-2014 01:48 PM
data shift from 1 remote machine to another remote machine raheelch General 7 03-09-2010 08:44 AM
LXer: “I’d suggest Linux - but..” - I’d suggest you get a clue, but.. LXer Syndicated Linux News 0 12-10-2007 01:50 PM
Oracle Workflow anirudh Programming 0 10-15-2004 03:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration