Remote Editing: Difference between revisions
No edit summary |
No edit summary |
||
(11 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
__FORCETOC__ | |||
= SSH = | |||
=== | First, ssh into VM like normal: | ||
<pre> | |||
ssh blazerid@cheaha.rc.uab.edu | |||
</pre> | |||
If you are trying to edit file on VM, not Cheaha, make sure you have tmux installed on system. | |||
<pre> | |||
# Ubuntu | |||
sudo apt install tmux | |||
# CentOS | |||
sudo yum install tmux | |||
</pre> | |||
Now, create a tmux session and detach right away. | |||
<pre> | |||
tmux new | |||
# Ctrl+B then D | |||
^B d | |||
</pre> | |||
You can exit this ssh connection now. | |||
<pre> | |||
exit | |||
</pre> | |||
Now ssh with remote command and special option <code> -t Force pseudo-terminal allocation.</code> | |||
<pre> | |||
ssh -t blazerid@cheaha.rc.uab.edu "tmux attach" | |||
</pre> | |||
or you can setup in your ssh config(<code>~/.ssh/config</code>): | |||
<pre> | |||
Host cheaha | |||
HostName cheaha.rc.uab.edu | |||
User <username> | |||
RequestTTY force | |||
RemoteCommand tmux attach | |||
</pre> | |||
With the setting you can ssh with: | |||
<pre> | |||
ssh cheaha | |||
</pre> | |||
Everytime you finish you editing on remote, either Cheaha or VM, use the detach command: | |||
<pre> | |||
# Ctrl+B then D | |||
^B d | |||
</pre> | |||
== With tmux Control Mode== | |||
Note: It only works with iTerm2 on MacOS | |||
Use <code>-CC</code> option with tmux | |||
<pre> | |||
ssh -t blazerid@cheaha.rc.uab.edu "tmux -CC attach" | |||
</pre> | |||
This will launch a new iTerm2 window contents your tmux session. | |||
You can create window and panel with iTerm2 shotcuts. | |||
== [[Visual Studio Code]] == | |||
Visual Studio Code has official extensions available to enable and facilitate remote development. Three extensions are available from the Visual Studio marketplace. They support remote development over SSH, in containers, and using Windows Subsystem for Linux (WSL). More detailed information on their use can be found at the documentation. To use the the SSH extension to access files on Cheaha, please follow the instructions in the documentation for installation. Once it is installed, follow these instructions to set up the SSH config file. The following assumes SSH is installed locally, and that a config file exists in the usual location for your operating system. The commands assume you have an open Visual Studio Code window. | |||
# Open the command palette, default hotkey "Ctrl + Shift + P". | |||
# Locate "Remote-SSH: Connect to Host..." by typing part of the command at the prompt. | |||
#: [[File:Remote-editing-vscode-palette.png]] | |||
# Click the command in the palette prompt. | |||
# Click "Configure SSH Hosts...". | |||
#: [[File:Remote-editing-vscode-ssh-choices.png]] | |||
# Choose the location of the existing config file. | |||
#: [[File:Remote-editing-vscode-ssh-file.png]] | |||
# In the new editor window that opened, add the following lines then save the file. | |||
<pre> | |||
Host cheaha | |||
HostName cheaha.rc.uab.edu | |||
User <username> | |||
</pre> | |||
The text <username> should be replaced by the user name you use to access Cheaha. The "User" line is not necessary but can save some time. | |||
=== Important Notes on Proper Usage === | |||
<span style="background:#FF0000">'''IMPORTANT!'''</span> | |||
The Remote-SSH extension of Visual Studio Code runs on the login node! All subprocesses spawned by Visual Studio Code will also run on the login node by default. As always, we should avoid using computation-heavy processes on the login node. The Visual Studio Code limitation is knonw, and due to the way the extension server code is deployed to Cheaha. [https://github.com/microsoft/vscode-remote-release/issues/1722 Issue #1722] has been opened on the relevant GitHub repository. Please click the thumbs-up emoji on the first post there to increase visibility and priority of the issue. | |||
It is possible to use the integrated terminal as normal with default hotkey "Ctrl + `" (backtick). This terminal behaves like the one on Open OnDemand, or other terminals, and can be used to start jobs as any other terminal. | |||
==== Things to Avoid ==== | |||
To minimize impact of remote development, avoid any of the following, or anything else that spawns a process. This is not a comprehensive list! | |||
* folders containing many files (>~1000 files) | |||
* folders containing large files (>100 MB or so) | |||
* debugging | |||
* accessing or running code within Jupyter notebooks. | |||
==== Working with Many or Large Files ==== | |||
If you must access a folder with many files or with large files, it is possible to have Visual Studio Code ignore those files or folders using a filter. Open ".vscode/settings.json" in the open folder and add an object like the following (remember the comma following the previous key-value pair, if any). Each key with the value "true" is ignored by Visual Studio Code when indexing or searching files. The keys use typical glob syntax. In the example below the following are excluded: | |||
* any folder containing a subfolder "datasets" is ignored, along with all contained subfolders and files. | |||
* the folder "ignore_children" in the root folder along with all contained folders and files. | |||
* the folder "node_modules" in the root folder along with all contained files. | |||
* the file "LARGE_DATA.sql" in the root folder | |||
<pre> | |||
"files.watcherExclude": { | |||
"**/datasets/**/*": true, | |||
"ignore_children/**/*": true, | |||
"node_modules/*": true, | |||
"LARGE_DATA.sql": true | |||
} | |||
</pre> |
Latest revision as of 20:21, 1 April 2020
SSH
First, ssh into VM like normal:
ssh blazerid@cheaha.rc.uab.edu
If you are trying to edit file on VM, not Cheaha, make sure you have tmux installed on system.
# Ubuntu sudo apt install tmux # CentOS sudo yum install tmux
Now, create a tmux session and detach right away.
tmux new # Ctrl+B then D ^B d
You can exit this ssh connection now.
exit
Now ssh with remote command and special option -t Force pseudo-terminal allocation.
ssh -t blazerid@cheaha.rc.uab.edu "tmux attach"
or you can setup in your ssh config(~/.ssh/config
):
Host cheaha HostName cheaha.rc.uab.edu User <username> RequestTTY force RemoteCommand tmux attach
With the setting you can ssh with:
ssh cheaha
Everytime you finish you editing on remote, either Cheaha or VM, use the detach command:
# Ctrl+B then D ^B d
With tmux Control Mode
Note: It only works with iTerm2 on MacOS
Use -CC
option with tmux
ssh -t blazerid@cheaha.rc.uab.edu "tmux -CC attach"
This will launch a new iTerm2 window contents your tmux session. You can create window and panel with iTerm2 shotcuts.
Visual Studio Code
Visual Studio Code has official extensions available to enable and facilitate remote development. Three extensions are available from the Visual Studio marketplace. They support remote development over SSH, in containers, and using Windows Subsystem for Linux (WSL). More detailed information on their use can be found at the documentation. To use the the SSH extension to access files on Cheaha, please follow the instructions in the documentation for installation. Once it is installed, follow these instructions to set up the SSH config file. The following assumes SSH is installed locally, and that a config file exists in the usual location for your operating system. The commands assume you have an open Visual Studio Code window.
- Open the command palette, default hotkey "Ctrl + Shift + P".
- Locate "Remote-SSH: Connect to Host..." by typing part of the command at the prompt.
- Click the command in the palette prompt.
- Click "Configure SSH Hosts...".
- Choose the location of the existing config file.
- In the new editor window that opened, add the following lines then save the file.
Host cheaha HostName cheaha.rc.uab.edu User <username>
The text <username> should be replaced by the user name you use to access Cheaha. The "User" line is not necessary but can save some time.
Important Notes on Proper Usage
IMPORTANT!
The Remote-SSH extension of Visual Studio Code runs on the login node! All subprocesses spawned by Visual Studio Code will also run on the login node by default. As always, we should avoid using computation-heavy processes on the login node. The Visual Studio Code limitation is knonw, and due to the way the extension server code is deployed to Cheaha. Issue #1722 has been opened on the relevant GitHub repository. Please click the thumbs-up emoji on the first post there to increase visibility and priority of the issue.
It is possible to use the integrated terminal as normal with default hotkey "Ctrl + `" (backtick). This terminal behaves like the one on Open OnDemand, or other terminals, and can be used to start jobs as any other terminal.
Things to Avoid
To minimize impact of remote development, avoid any of the following, or anything else that spawns a process. This is not a comprehensive list!
- folders containing many files (>~1000 files)
- folders containing large files (>100 MB or so)
- debugging
- accessing or running code within Jupyter notebooks.
Working with Many or Large Files
If you must access a folder with many files or with large files, it is possible to have Visual Studio Code ignore those files or folders using a filter. Open ".vscode/settings.json" in the open folder and add an object like the following (remember the comma following the previous key-value pair, if any). Each key with the value "true" is ignored by Visual Studio Code when indexing or searching files. The keys use typical glob syntax. In the example below the following are excluded:
- any folder containing a subfolder "datasets" is ignored, along with all contained subfolders and files.
- the folder "ignore_children" in the root folder along with all contained folders and files.
- the folder "node_modules" in the root folder along with all contained files.
- the file "LARGE_DATA.sql" in the root folder
"files.watcherExclude": { "**/datasets/**/*": true, "ignore_children/**/*": true, "node_modules/*": true, "LARGE_DATA.sql": true }