vscode.md 4.64 KB
Newer Older
Chris Hines's avatar
Chris Hines committed
1
2
## Introduction

Chris Hines's avatar
Chris Hines committed
3

Chris Hines's avatar
Chris Hines committed
4
So you'd like to use VS Code, but your data is on M3. No problem. You want a VS Code remote server
Chris Hines's avatar
Chris Hines committed
5

Chris Hines's avatar
Chris Hines committed
6
The official VS Code documentation on this is here https://code.visualstudio.com/docs/remote/ssh
Chris Hines's avatar
Chris Hines committed
7
8
9

By default, if you follow those instructions, you will end up running the VS Code remote server on the login node. Please don't do this, the login nodes are a shared resources and we would rather allocate you a resource just for you. 

Chris Hines's avatar
Chris Hines committed
10
11
## Steps

Chris Hines's avatar
Chris Hines committed
12

Chris Hines's avatar
Chris Hines committed
13
1. Setup VS Code (install remote server extension)
Chris Hines's avatar
Chris Hines committed
14
15
    
    Please follow the excelent instructions here https://code.visualstudio.com/docs/remote/ssh#_installation   ... When you get to the section "Connect to a remote host" please come back here
Chris Hines's avatar
Chris Hines committed
16
1. Setup ssh-agent and keys (optional HIGHLY recommended)
Chris Hines's avatar
Chris Hines committed
17
 
Chris Hines's avatar
Chris Hines committed
18
   i. Generate a key
Chris Hines's avatar
Chris Hines committed
19
 
Chris Hines's avatar
Chris Hines committed
20
21
22
23
24
    If you are still using passwords, you should definitly switch to keys open a terminal (mac and linux) or a powershell (windows) and run the command
    ```
    ssh-keygen -t ed25519 
    ``` 
    you will be asked to enter a passphrase. This is used to encrypt the output file on your computer.
Chris Hines's avatar
Chris Hines committed
25

Chris Hines's avatar
Chris Hines committed
26
    Next enter
Chris Hines's avatar
Chris Hines committed
27

Chris Hines's avatar
Chris Hines committed
28
29
30
    ```
    cat ~/.ssh/id_ed25519.pub
    ```
Chris Hines's avatar
Chris Hines committed
31
 
Chris Hines's avatar
Chris Hines committed
32
    copy the line of text printed out. Using Strudel2 (beta.cloud.cvl.org.au), select Terminal -> Run on Login node when the new window opens type
Chris Hines's avatar
Chris Hines committed
33
  
Chris Hines's avatar
Chris Hines committed
34
35
36
    ```
    echo <paste the line you just copied> >> .ssh/authorized_keys
    ```
Chris Hines's avatar
Chris Hines committed
37
   i. Setup the agent
Chris Hines's avatar
Chris Hines committed
38
39
    
    Windows only (the agent is already running on linux and mac)
Chris Hines's avatar
Chris Hines committed
40

Chris Hines's avatar
Chris Hines committed
41
    ### ALERT ALERT THIS DOCUMENTATION IS INCOMPLETE!!!!! 
Chris Hines's avatar
Chris Hines committed
42
 
Chris Hines's avatar
Chris Hines committed
43
    I *think* you may have to install openssh on windows, but it may be pre-installed.
Chris Hines's avatar
Chris Hines committed
44

Chris Hines's avatar
Chris Hines committed
45
46
47
48
     ```
     To install the OpenSSH components:
       Open Settings, select Apps > Apps & Features, then select Optional Features.
        Scan the list to see if the OpenSSH is already installed. If not, at the top of the page, select Add a feature, then:
Chris Hines's avatar
Chris Hines committed
49
        On Windows 10, find OpenSSH Client, then click Install
Chris Hines's avatar
Chris Hines committed
50
     ```
Chris Hines's avatar
Chris Hines committed
51
 
Chris Hines's avatar
Chris Hines committed
52
     Next you need to start the OpenSSH SSH agent. You have two options
Chris Hines's avatar
Chris Hines committed
53
 
Chris Hines's avatar
Chris Hines committed
54
     ### Via GUI:
Chris Hines's avatar
Chris Hines committed
55

Chris Hines's avatar
Chris Hines committed
56
     I think you command
Chris Hines's avatar
Chris Hines committed
57

Chris Hines's avatar
Chris Hines committed
58
     1. Press the windows key (to begin search) and type "Services". Hit enter to open the services app
Chris Hines's avatar
Chris Hines committed
59

Chris Hines's avatar
Chris Hines committed
60
     2. Scroll down to OpenSSH Authentication Agent and double click
Chris Hines's avatar
Chris Hines committed
61

Chris Hines's avatar
Chris Hines committed
62
     3. Change "Startup type" to "Automatic"
Chris Hines's avatar
Chris Hines committed
63

Chris Hines's avatar
Chris Hines committed
64
     4. Click start
Chris Hines's avatar
Chris Hines committed
65

Chris Hines's avatar
Chris Hines committed
66
   ### Via PowerShell:
Chris Hines's avatar
Chris Hines committed
67

Chris Hines's avatar
Chris Hines committed
68
   Start a powershell as administrator and run the following
Chris Hines's avatar
Chris Hines committed
69

Chris Hines's avatar
Chris Hines committed
70
71
72
73
74
   ```
   Install-Module -Force OpenSSHUtils -Scope AllUsers
   Get-Service -Name ssh-agent | Set-Service -StartupType Automatic
   Start-Service ssh-agent
   ```
Chris Hines's avatar
Chris Hines committed
75
76


Chris Hines's avatar
Chris Hines committed
77
78
79
80
81
   Open a terminal and type `ssh-add .ssh/id_ed25519` you'll be asked for that key passphrase, but then your computer will remember the key (until the next reboot)

3. Configure VS Code
 
 Skip down to here https://code.visualstudio.com/docs/remote/ssh#_remember-hosts-and-advanced-settings. If you are on linux or mac, for your "SSH Connection Command" enter
Chris Hines's avatar
Chris Hines committed
82
83
 
 ```
Chris Hines's avatar
Chris Hines committed
84
 ssh -l <username> VSCode -o ProxyCommand="ssh <username>@m3.massive.org.au /usr/local/sv2/sshnc.sh"
Chris Hines's avatar
Chris Hines committed
85
 ```
Chris Hines's avatar
Chris Hines committed
86

Chris Hines's avatar
Chris Hines committed
87
 On windows enter
Chris Hines's avatar
Chris Hines committed
88
 ```
Chris Hines's avatar
Chris Hines committed
89
  ssh -l <username> VSCode -o ProxyCommand="ssh.exe <username>@m3.massive.org.au /usr/local/sv2/sshnc.sh"
Chris Hines's avatar
Chris Hines committed
90
 ```
Chris Hines's avatar
Chris Hines committed
91

Chris Hines's avatar
Chris Hines committed
92
 The proxycommand allows us to connect, not to the login nodes but to a node allocated just to you. This is different than a regular  VSCode setup because youre on an HPC cluster, not a regular server.
Chris Hines's avatar
Chris Hines committed
93

Chris Hines's avatar
Chris Hines committed
94
95
96
4. Allocate a computer for the remote server
 
 Using strudel2 https://beta.cloud.cvl.org.au login to CVL and select the VS Code application on the left. Fill in how many CPUs which GPU and how much RAM you need for how long and click launch
Chris Hines's avatar
Chris Hines committed
97

Chris Hines's avatar
Chris Hines committed
98
5. Start the remote server
Chris Hines's avatar
Chris Hines committed
99

Chris Hines's avatar
Chris Hines committed
100
 Switching back to vscode, Remote-ssh: Connect to host and select the VS Code host If you didn't add the key to the agent, VS Code will ask you for either you key passphrase or your M3 password. It will ask twice (once to the connect to the login nodes, then again to connect to the node running the remote server)
Chris Hines's avatar
Chris Hines committed
101

Chris Hines's avatar
Chris Hines committed
102
 VS Code will also ask you what type of server it is (linux)
Chris Hines's avatar
Chris Hines committed
103

Chris Hines's avatar
Chris Hines committed
104
 Then you should be good to good
Chris Hines's avatar
Chris Hines committed
105

Chris Hines's avatar
Chris Hines committed
106
## FAQ:
Chris Hines's avatar
Chris Hines committed
107
108
109
110

Q: I see a message about "Connection Reset by peer":

A: This happend to me a couple of times. It turned out the compute node had banned the login node due to too many failed passwords. Wait 10 minutes, try again. If its still wonky let us know (also switch to keys ASAP)
Chris Hines's avatar
Chris Hines committed
111

Chris Hines's avatar
Chris Hines committed
112
Q: I keep getting prompted for a password even though I'm using a key
Chris Hines's avatar
Chris Hines committed
113

Chris Hines's avatar
Chris Hines committed
114
115
116
117
118
A: Check that your connection command includes the username everwhere you need it (it should be in there twice, once for the login node and once for the compute node)

Q: I got an error message about posix spawn

A: You're probably on windows. Check tha tyou used the windows specific command line with ssh.exe instead of ssh