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

**URL:** <https://forum.cursor.com/t/ssh-config-connect-via-ssh-not-using-hostname-properly/115442>\
**Category:** Bug Reports\
**Created:** [July 8, 2025, 7:10pm UTC](https://forum.cursor.com/t/ssh-config-connect-via-ssh-not-using-hostname-properly/115442 "2025-07-08T19:10:51Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![NorseGaud](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/norsegaud/32/69427_2.png) [@NorseGaud](https://forum.cursor.com/u/NorseGaud)\
**Post date:** [July 8, 2025, 7:10pm UTC](https://forum.cursor.com/t/ssh-config-connect-via-ssh-not-using-hostname-properly/115442/1 "2025-07-08T19:10:51Z")

</div>

### Describe the Bug

```auto
Host test123
        HostName server-dev@SERVER1.com
        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.

```auto
[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:

```auto
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.

```

```auto
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

 ![Screenshot 2025-07-08 at 2.03.58 PM.png](https://us1.discourse-cdn.com/cursor1/original/3X/7/6/7666395de7183c8f177b81fa49643e4ec9ba2e81.png)

### 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

---

<div class="post-metadata">

**Author:** ![NorseGaud](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/norsegaud/32/69427_2.png) [@NorseGaud](https://forum.cursor.com/u/NorseGaud)\
**Post date:** [July 11, 2025, 7:55pm UTC](https://forum.cursor.com/t/ssh-config-connect-via-ssh-not-using-hostname-properly/115442/2 "2025-07-11T19:55:45Z")

</div>

bump?

---

<div class="post-metadata">

**Author:** ![ravirahman](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/ravirahman/32/20386_2.png) [@ravirahman](https://forum.cursor.com/u/ravirahman)\
**Post date:** [July 11, 2025, 9:52pm UTC](https://forum.cursor.com/t/ssh-config-connect-via-ssh-not-using-hostname-properly/115442/4 "2025-07-11T21:52:44Z")

</div>

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:

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

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

```

---

<div class="post-metadata">

**Author:** ![ravirahman](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/ravirahman/32/20386_2.png) [@ravirahman](https://forum.cursor.com/u/ravirahman)\
**Post date:** [July 12, 2025, 3:09am UTC](https://forum.cursor.com/t/ssh-config-connect-via-ssh-not-using-hostname-properly/115442/7 "2025-07-12T03:09:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![NorseGaud](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/norsegaud/32/69427_2.png) [@NorseGaud](https://forum.cursor.com/u/NorseGaud)\
**Post date:** [July 21, 2025, 6:26pm UTC](https://forum.cursor.com/t/ssh-config-connect-via-ssh-not-using-hostname-properly/115442/10 "2025-07-21T18:26:31Z")

</div>

bump

---

<div class="post-metadata">

**Author:** ![ravirahman](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/ravirahman/32/20386_2.png) [@ravirahman](https://forum.cursor.com/u/ravirahman)\
**Post date:** [July 22, 2025, 2:55am UTC](https://forum.cursor.com/t/ssh-config-connect-via-ssh-not-using-hostname-properly/115442/12 "2025-07-22T02:55:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![NorseGaud](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/norsegaud/32/69427_2.png) [@NorseGaud](https://forum.cursor.com/u/NorseGaud)\
**Post date:** [July 22, 2025, 10:30pm UTC](https://forum.cursor.com/t/ssh-config-connect-via-ssh-not-using-hostname-properly/115442/13 "2025-07-22T22:30:18Z")

</div>

My .ssh/config:

```auto
Host nathan@server-dev.domain.com
        HostName server-dev.domain.com
        IdentityFile ~/.ssh/id_rsa
        User nathan

Host automation@server-dev.domain
	HostName server-dev.domain
	IdentityFile ~/.ssh/automation-service-user
	User automation

```

```auto
[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: remote-ssh@0.113.1
[15:14:16.406] darwin arm64
[15:14:16.410] SSH Resolver called for host: nathan@server-dev.domain
[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","nathan@server-dev.domain.com"],"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 nathan@server-dev.domain.com
[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> nathan@server-dev.domain.com: 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 nathan@server-dev.domain.com
local-server-1> Spawned ssh, pid=58826
OpenSSH_9.9p2, LibreSSL 3.3.6
debug1: Server host key: ssh-ed25519 SHA256:4GrHaSF0kJ56YLp64u6WuozCXecuZUut2SMFhAnRG9E
nathan@server-dev.domain: 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] ------

```

---

<div class="post-metadata">

**Author:** ![ravirahman](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/ravirahman/32/20386_2.png) [@ravirahman](https://forum.cursor.com/u/ravirahman)\
**Post date:** [July 23, 2025, 6:14am UTC](https://forum.cursor.com/t/ssh-config-connect-via-ssh-not-using-hostname-properly/115442/15 "2025-07-23T06:14:11Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![NorseGaud](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/norsegaud/32/69427_2.png) [@NorseGaud](https://forum.cursor.com/u/NorseGaud)\
**Post date:** [August 6, 2025, 3:14am UTC](https://forum.cursor.com/t/ssh-config-connect-via-ssh-not-using-hostname-properly/115442/18 "2025-08-06T03:14:16Z")

</div>

bump

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/system/32/99069_2.png) [@system](https://forum.cursor.com/u/system)\
**Post date:** [September 9, 2025, 1:22am UTC](https://forum.cursor.com/t/ssh-config-connect-via-ssh-not-using-hostname-properly/115442/22 "2025-09-09T01:22:29Z")

</div>

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