1

通过身份验证登录 ssh 工作正常。

C:\Users\${DEVELOPER_NAME}>ssh ${HOST_IP_ADDRESS} -l ${DEVELOPER_NAME} -p ${SSHD_PORT} -i D:\prefix\PuTTY\${OPENSSH_FORMAT_PRIVATE_KEY}
Last login: Sun May  5 15:27:50 2019 from 10.40.171.44
Welcome to ...
[${DEVELOPER_NAME}@${HOST_AKA} ~]$

但是 sshd 运行在 36000 而不是默认的 22 端口上,我怎么能告诉 vs code remote-ssh 插件

Host ${DEVELOPER_NAME}@${HOST_IP_ADDRESS}
HostName ${HOST_IP_ADDRESS}:${SSHD_PORT}
User ${DEVELOPER_NAME}
Port ${SSHD_PORT}
IdentityFile D:\prefix\PuTTY\${OPENSSH_FORMAT_PRIVATE_KEY}

这种方式给了我

Can't connect to ${DEVELOPER_NAME}@${HOST_IP_ADDRESS}: unreachable or not Linux x86_64 (ssh: connect to host ${HOST_IP_ADDRESS} port 22: Connection refused)

${DEVELOPER_NAME}@${HOST_IP_ADDRESS}:${SSHD_PORT}

Remote-SSH: Connect to Host...给我

Can't connect to ${DEVELOPER_NAME}@${HOST_IP_ADDRESS}:${SSHD_PORT}: unreachable or not Linux x86_64 (ssh: Could not resolve hostname ${HOST_IP_ADDRESS}:${SSHD_PORT}: Name or service not known)
4

1 回答 1

0

谢谢你的问题,我解决了。您可能已经想通了……您不需要为 HostName 添加端口。只需编写端口即可。

Host ${HOST_NICKNAME}
    User ${USER_ID_HOST}
    HostName ${HOST_IP_ADDRESS}
    Port ${SSHD_PORT}
    IdentityFile ~/.ssh/id_rsa-remote-ssh
于 2019-05-16T17:33:38.817 回答