设置remote以使用ssh的指定端口

Jay*_*Jay 9 git

我有ssh键设置工作在指定的端口(例如12345)并发出以下git命令来设置本地仓库的原点.

git remote add origin myusername@mydomain.com:12345/path/to/public_html/files/
Run Code Online (Sandbox Code Playgroud)

当我尝试推送到原点时,我收到以下错误消息.

ssh: connect to host mydomain.com port 22: Connection refused
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

我如何设置原点,以便它使用正确的ssh端口?

Rya*_*art 12

要指定自定义端口,您必须添加ssh://前缀.否则,git会将您的12345解释为项目路径的一部分.请参阅git-pull文档中的URL.所以:

git remote add origin ssh://myusername@mydomain.com:12345/path/to/public_html/files/
Run Code Online (Sandbox Code Playgroud)