Remote Editing: Difference between revisions

From Cheaha
Jump to navigation Jump to search
No edit summary
No edit summary
Line 22: Line 22:
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.
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.


== SSH ==
= SSH =
 
=== With tmux ===


First, ssh into VM like normal:
First, ssh into VM like normal:
Line 55: Line 53:
</pre>
</pre>


This time, ssh with remote command and special option <code> -t Force pseudo-terminal allocation.</code>
Now ssh with the following command:
<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
 
ssh with remote command and special option <code> -t Force pseudo-terminal allocation.</code>
<pre>
<pre>
ssh -t blazerid@cheaha.rc.uab.edu "tmux -CC attach"
ssh -t blazerid@cheaha.rc.uab.edu "tmux -CC attach"
</pre>
</pre>

Revision as of 19:43, 1 April 2020


Visual Studio Code

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.

  1. Open the command palette, default hotkey "Ctrl + Shift + P".
  2. Locate "Remote-SSH: Connect to Host..." by typing part of the command at the prompt.
    Remote-editing-vscode-palette.png
  3. Click the command in the palette prompt.
  4. Click "Configure SSH Hosts...".
    Remote-editing-vscode-ssh-choices.png
  5. Choose the location of the existing config file.
    Remote-editing-vscode-ssh-file.png
  6. 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.

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 the following command:

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

ssh with remote command and special option -t Force pseudo-terminal allocation.

ssh -t blazerid@cheaha.rc.uab.edu "tmux -CC attach"