.ssh/config / Connect via SSH not using HostName properly

Describe the Bug

Host test123
        HostName [email protected]
        User nathan
        IdentityFile ~/.ssh/id_rsa

It properly shows as test123 in the list of SSH remotes.

Yet, it tries connecting to the Host which is not how it should work if HostName is specified.

[14:07:44.730] Received install output: local-server-1> Running ssh connection command: ssh -v -T -D 51822 -o ConnectTimeout=15 test123

From the official SSH docs:

Host

Restricts the following declarations to be only for those hosts that match one of the patterns given after the keyword. The pattern is matched against the host name given on the command line.
HostName

Specifies the real host name to log into. This can be used to specify nicknames or abbreviations for hosts. The default is the name given on the command line. Numeric IP addresses are also permitted (both on the command line and in HostName specifications).

Why? Because I have multiple users I need to log into on the same server.

Steps to Reproduce

Use my example .ssh/config entry

Expected Behavior

It uses HostName to connect to

Screenshots / Screen Recordings

Operating System

MacOS

Current Cursor Version (Menu → About Cursor → Copy)

Version: 1.2.2
VSCode Version: 1.99.3
Commit: faa03b17cce93e8a80b7d62d57f5eda6bb6ab9f0
Date: 2025-07-07T06:08:52.104Z
Electron: 34.5.1
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Darwin arm64 24.5.0

Does this stop you from using Cursor

No - Cursor works, but with this issue

bump?

Hi @NorseGaud , this is intended – we’ll attempt to connect to test123. Openssh will then read your config file to apply the correct options for the (psuedo) host. If you have multiple users, I’d recommend something like this:

Host test123nathan
        HostName SERVER1.com
        User nathan
        IdentityFile ~/.ssh/id_rsa

Host test123foo
        HostName SERVER1.com
        User foo
        IdentityFile ~/.ssh/id_rsa

Yes, this is intended – Oepnssh will apply the config file when it sees the host test123. Is the connection working, or is it failing to connect?

bump

Could you share the logs from the “Remote - SSH” output window where it fails to connect?

My .ssh/config:

Host [email protected]
        HostName server-dev.domain.com
        IdentityFile ~/.ssh/id_rsa
        User nathan

Host [email protected]
	HostName server-dev.domain
	IdentityFile ~/.ssh/automation-service-user
	User automation
[15:14:16.394] Log Level: 2
[15:14:16.401] SSH Resolver called for "ssh-remote+7b22686f73744e616d65223a227365727665722d6465762e776f6f6c7961692e636f6d222c2275736572223a226e617468616e227d", attempt 1
[15:14:16.402] "remote.SSH.useLocalServer": true
[15:14:16.402] "remote.SSH.useExecServer": true
[15:14:16.402] "remote.SSH.path": 
[15:14:16.402] "remote.SSH.configFile": 
[15:14:16.402] "remote.SSH.useFlock": true
[15:14:16.402] "remote.SSH.lockfilesInTmp": false
[15:14:16.402] "remote.SSH.localServerDownload": auto
[15:14:16.402] "remote.SSH.remoteServerListenOnSocket": false
[15:14:16.402] "remote.SSH.showLoginTerminal": false
[15:14:16.402] "remote.SSH.defaultExtensions": []
[15:14:16.402] "remote.SSH.loglevel": 2
[15:14:16.402] "remote.SSH.enableDynamicForwarding": true
[15:14:16.402] "remote.SSH.enableRemoteCommand": false
[15:14:16.402] "remote.SSH.serverPickPortsFromRange": {}
[15:14:16.403] "remote.SSH.serverInstallPath": {}
[15:14:16.403] "remote.SSH.permitPtyAllocation": false
[15:14:16.403] "remote.SSH.preferredLocalPortRange: undefined
[15:14:16.403] "remote.SSH.useCurlAndWgetConfigurationFiles: false
[15:14:16.406] VS Code version: 1.2.4
[15:14:16.406] Remote-SSH version: [email protected]
[15:14:16.406] darwin arm64
[15:14:16.410] SSH Resolver called for host: [email protected]
[15:14:16.410] Setting up SSH remote "server-dev.domain"
[15:14:16.411] Acquiring local install lock: /var/folders/vt/byhkgjmd4pq6v8j2f9tsghf40000gn/T/vscode-remote-ssh-3358c077-install.lock
[15:14:16.412] Looking for existing server data file at /Users/nathanpierce/Library/Application Support/Cursor/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-3358c077-a8e95743c5268be73767c46944a71f4465d05c90-0.113.1-es/data.json
[15:14:16.413] Using commit id "a8e95743c5268be73767c46944a71f4465d05c90" and quality "stable" for server
[15:14:16.415] Install and start server if needed
[15:14:16.416] PATH: /opt/homebrew/opt/openjdk@17/bin:/Users/nathanpierce/apache-maven-4.0.0-beta-3/bin:/Users/nathanpierce/.pyenv/shims:/opt/homebrew/opt/ssh-copy-id/bin:/Users/nathanpierce/.nvm/versions/node/v22.14.0/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Applications/Wireshark.app/Contents/MacOS:/Applications/Little Snitch.app/Contents/Components:/Users/nathanpierce/go/bin/:/Users/nathanpierce/bin
[15:14:16.417] Checking ssh with "ssh -V"
[15:14:16.421] > OpenSSH_9.9p2, LibreSSL 3.3.6

[15:14:16.423] askpass server listening on /var/folders/vt/byhkgjmd4pq6v8j2f9tsghf40000gn/T/vscode-ssh-askpass-af2e511ae987fe9533738cdc45d7518e216ab112.sock
[15:14:16.424] Spawning local server with {"serverId":1,"ipcHandlePath":"/var/folders/vt/byhkgjmd4pq6v8j2f9tsghf40000gn/T/vscode-ssh-askpass-69ca62f694c56e4d29445827c6a7616d4353f177.sock","sshCommand":"ssh","sshArgs":["-v","-T","-D","62809","-o","ConnectTimeout=15","[email protected]"],"serverDataFolderName":".cursor-server","dataFilePath":"/Users/nathanpierce/Library/Application Support/Cursor/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-3358c077-a8e95743c5268be73767c46944a71f4465d05c90-0.113.1-es/data.json"}
[15:14:16.424] Local server env: {"SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.xunsvDH3eC/Listeners","SHELL":"/bin/zsh","DISPLAY":"1","ELECTRON_RUN_AS_NODE":"1","SSH_ASKPASS":"/Users/nathanpierce/.cursor/extensions/ms-vscode-remote.remote-ssh-0.113.1/out/local-server/askpass.sh","VSCODE_SSH_ASKPASS_NODE":"/Applications/Cursor.app/Contents/Frameworks/Cursor Helper (Plugin).app/Contents/MacOS/Cursor Helper (Plugin)","VSCODE_SSH_ASKPASS_EXTRA_ARGS":"","VSCODE_SSH_ASKPASS_MAIN":"/Users/nathanpierce/.cursor/extensions/ms-vscode-remote.remote-ssh-0.113.1/out/askpass-main.js","VSCODE_SSH_ASKPASS_HANDLE":"/var/folders/vt/byhkgjmd4pq6v8j2f9tsghf40000gn/T/vscode-ssh-askpass-af2e511ae987fe9533738cdc45d7518e216ab112.sock"}
[15:14:16.424] Spawned 58816
[15:14:16.481] > local-server-1> Running ssh connection command: ssh -v -T -D 62809 -o ConnectTimeout=15 [email protected]
[15:14:16.483] > local-server-1> Spawned ssh, pid=58826
[15:14:16.486] stderr> OpenSSH_9.9p2, LibreSSL 3.3.6
[15:14:16.831] stderr> debug1: Server host key: ssh-ed25519 SHA256:4GrHaSF0kJ56YLp64u6WuozCXecuZUut2SMFhAnRG9E
[15:14:17.218] stderr> [email protected]: Permission denied (publickey).
[15:14:17.220] > local-server-1> ssh child died, shutting down
[15:14:17.230] Local server exit: 0
[15:14:17.230] Received install output: local-server-1> Running ssh connection command: ssh -v -T -D 62809 -o ConnectTimeout=15 [email protected]
local-server-1> Spawned ssh, pid=58826
OpenSSH_9.9p2, LibreSSL 3.3.6
debug1: Server host key: ssh-ed25519 SHA256:4GrHaSF0kJ56YLp64u6WuozCXecuZUut2SMFhAnRG9E
[email protected]: Permission denied (publickey).
local-server-1> ssh child died, shutting down

[15:14:17.235] Resolver error: Error: Permission denied (publickey).
	at m.Create (/Users/nathanpierce/.cursor/extensions/ms-vscode-remote.remote-ssh-0.113.1/out/extension.js:2:501230)
	at /Users/nathanpierce/.cursor/extensions/ms-vscode-remote.remote-ssh-0.113.1/out/extension.js:2:497704
	at t.handleInstallOutput (/Users/nathanpierce/.cursor/extensions/ms-vscode-remote.remote-ssh-0.113.1/out/extension.js:2:498474)
	at e (/Users/nathanpierce/.cursor/extensions/ms-vscode-remote.remote-ssh-0.113.1/out/extension.js:2:560424)
	at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
	at async /Users/nathanpierce/.cursor/extensions/ms-vscode-remote.remote-ssh-0.113.1/out/extension.js:2:582481
	at async t.withShowDetailsEvent (/Users/nathanpierce/.cursor/extensions/ms-vscode-remote.remote-ssh-0.113.1/out/extension.js:2:586100)
	at async /Users/nathanpierce/.cursor/extensions/ms-vscode-remote.remote-ssh-0.113.1/out/extension.js:2:557129
	at async T (/Users/nathanpierce/.cursor/extensions/ms-vscode-remote.remote-ssh-0.113.1/out/extension.js:2:555180)
	at async t.resolveWithLocalServer (/Users/nathanpierce/.cursor/extensions/ms-vscode-remote.remote-ssh-0.113.1/out/extension.js:2:556669)
	at async k (/Users/nathanpierce/.cursor/extensions/ms-vscode-remote.remote-ssh-0.113.1/out/extension.js:2:579620)
	at async t.resolve (/Users/nathanpierce/.cursor/extensions/ms-vscode-remote.remote-ssh-0.113.1/out/extension.js:2:583511)
	at async /Users/nathanpierce/.cursor/extensions/ms-vscode-remote.remote-ssh-0.113.1/out/extension.js:2:851172
[15:14:17.244] ------

Hi @NorseGaud, this looks like it’s an issue with the permissions of the remote server. Can you add this key to the authorized_keys on the remote host?

bump

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.