git/stash上的publickey-authentication for ssh无法正常工作

Vin*_*nce 2 git ssh public-key bitbucket-server

我正在尝试使用git/stash,但我对publickey-authentication有点问题.这是发生的事情:

hannibal是存储服务器上的用户.hannibal具有一个存储库的读/写权限和添加到其存储帐户的ssh-publickey.我现在通过创建一个存储库

git init
Run Code Online (Sandbox Code Playgroud)

add&commit测试文件test.然后我想添加stash-repository作为origin

git remote add origin hannibal@stash:7999/path/to/repository.git
Run Code Online (Sandbox Code Playgroud)

这不会产生进一步的产出.现在我试着push

git push origin master
Run Code Online (Sandbox Code Playgroud)

这反过来要求我输入密码(这很奇怪,因为它应该通过publickey进行身份验证).我输入密码,屏幕上显示以下错误消息:

Could not chdir to home directory /home/hannibal: No such file or directory
fatal: '7999/path/to/repository.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

URL肯定是正确的,因为它是藏匿给我的那个.此外,在存储服务器上启用了ssh.我在这里错过了什么?

Rog*_*Rog 6

ssh遥控器的URL应该以ssh://为前缀,用户名应该是git(Stash会自动为你的hannibal用户找到正确的密钥).URL的完整形式是:

ssh://git@server:7999/project/repo.git
Run Code Online (Sandbox Code Playgroud)

对于http URL,使用用户名和http端口(默认为7990)