How to use codespaces index on remote server via SSH
One of the most powerful tools of Cursor is codespace indexing. However, on remote servers, this function is prone to fail due to network limitations or fire walls. The functionality of Cursor has been greatly compromised. We can enable remote hosts to access external websites through the network interface of their own computers.
Install a local client
Install Clash/V2Ray, open an HTTP or SOCKS port (e.g. 7890) on your computer, and then forward through an SSH tunnel. Here, I installed Clash For Window (CFW).
And you can set the port like this.
Check the port
In PowerShell on windows, you can run the following command to check the port
1 | netstat -ano | findstr LISTEN |
Once you see output like: TCP 127.0.0.1:7890 0.0.0.0:0 LISTENING 32080
, it means the client works well.
Establish an SSH tunnel
Still in PowerShell on windows, run:
1 | ssh -R 8888:127.0.0.1:7890 user@remote_host |
Then you will connect to the remote host.
Set the environment variables on the remote server
After logging in to the remote server, enter at the terminal:
1 | export http_proxy=http://127.0.0.1:8888 |
You can of course use other number rather than 8888, or add these commands to your ~/.bashrc
file and then source it.
This will allow most of the CLI tools (e.g. curl, wget, git
) on the remote machine to access the extranet through your local proxy.
Test accessibility to outer websites
You can use curl, ping, wget
to test accessibility to outer websites. For example:
Set .ssh
on your own computer
To avoid running ssh -R 8888:127.0.0.1:7890 user@remote_host
every time you want to use this function, you can modify .ssh
on your own computer. For example you have:
1 | Host yuan.hsres.pitt.edu |
You can change it like:
1 | Host yuan.hsres.pitt.edu |
In Cursor settings
Use ctl+,
open settings, and search ssh proxy
:
Edit settings.json
:
And then restart Cursor.
Finally
It work!