hexo-deployer-git icon indicating copy to clipboard operation
hexo-deployer-git copied to clipboard

hexo-deployer-git does not reference my ~/.ssh/config settings, OR it is not using my ssh user agent

Open MSoup opened this issue 1 year ago • 3 comments

Check List

  • [X] I have already read README.
  • [X] I have already searched existing issues and they are not help to me.
  • [X] I examined error or warning messages and it's difficult to solve.
  • [X] I am using the latest version of this repository.
  • [X] I am using the latest version of Hexo.
  • [X] My Node.js is matched the required version.

Describe the bug

npx hexo deploy does not reference my ~/.ssh/config or it is not using my ssh user agent.

As a result, it hangs at the deploy step.

...
INFO  90 files generated in 743 ms
INFO  Deploying: git
INFO  Clearing .deploy_git folder...
INFO  Copying files from public folder...

It does not proceed from the above and I have to restart my computer in order to get my daemon back in a functioning state (colima).

Expected behavior

git authenticates via my ssh user agent, checks the ~/.ssh/config file to map personal.github.com to github.com before finally authenticating with the remote and pushing my static bundle

How to reproduce

  1. From within dev container, run npx hexo clean && npx hexo deploy

Screenshots

No response

Environment information

hexo: 7.2.0
hexo-cli: 4.3.2
os: linux 6.5.0-42-generic Debian GNU/Linux 12 (bookworm) 12 (bookworm)
node: 20.15.0
acorn: 8.11.3
ada: 2.7.8
ares: 1.28.1
base64: 0.5.2
brotli: 1.1.0
cjs_module_lexer: 1.2.2
cldr: 45.0
icu: 75.1
llhttp: 8.1.2
modules: 115
napi: 9
nghttp2: 1.61.0
nghttp3: 0.7.0
ngtcp2: 1.1.0
openssl: 3.0.13+quic
simdutf: 5.2.8
tz: 2024a
undici: 6.13.0
unicode: 15.1
uv: 1.46.0
uvwasi: 0.0.21
v8: 11.3.244.8-node.23
zlib: 1.3.0.1-motley-7d77fb7

Additional context

I have tested from within my dev container that ssh user agent forwarding is working as expected, and regular git commands work as well.

From within my dev container

root@cc7327dbf799:/app# ssh-add -l
256 SHA256:/pARioj... (ED25519)

root@cc7327dbf799:/app# git pull
remote: Enumerating objects: 49, done.
remote: Counting objects: 100% (49/49), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 32 (delta 14), reused 30 (delta 12), pack-reused 0
Unpacking objects: 100% (32/32), 9.27 KiB | 50.00 KiB/s, done.

My remote URL looks like

root@cc7327dbf799:/app# git remote -v
origin  [email protected]:<user>/<repo>.git (fetch)
origin  [email protected]:<user>/<repo>.git (push)

And my ~/.ssh/config looks like

Host personal.github.com
  HostName github.com

I don't know how to further inspect what is happening. I know that with git I can do something like GIT_TRACE=true git pull, but I cannot do the same for this tool in order to further debug.

MSoup avatar Jul 04 '24 05:07 MSoup

https://github.com/hexojs/hexo-deployer-git/blob/ef1a2027e4fbc19e5d1fc92c0f5f4f7f6d1ddf87/lib/deployer.js#L94-L109

Judging from the logs you provided, it's stuck at the step of copying files, which has nothing to do with ssh.

Or maybe you haven't provide complete logs.

uiolee avatar Jul 08 '24 07:07 uiolee

Thank you for the observations. I decided to try the same steps without the dev container to focus on the topic of git/ssh and not possible permissions issues within the dev container.

Observations

Now the public folder is deployed, but as the deployer doesn't reference my ~/.ssh/config file, it is using the wrong private key to deploy to the gh pages branch. (it shows my other account as the account that pushed to the gh-pages branch)

Temp Fix

The only temporary fix I know right now is forcing the deploy script to use a different "GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL, like

"deploy": "GIT_AUTHOR_NAME='Foo' GIT_AUTHOR_EMAIL='[email protected]' hexo deploy",

I have also tried setting name and email from within _config.yml but the deployer doesn't seem to pick them up either.

Is there anything I can do to produce more helpful logs?

MSoup avatar Jul 08 '24 07:07 MSoup

deployer doesn't reference my ~/.ssh/config file

deployer just simply exec git commit git push and so on. It's possible that you haven't configured ssh or git correctly.


I have also tried setting name and email from within _config.yml but the deployer doesn't seem to pick them up either.

#353 has solved this issue but has not been published to npmjs yet.

you can try:

npm i https://github.com/hexojs/hexo-deployer-git/tree/880a3c3332d82743521f86737b7d815b128e622b

uiolee avatar Oct 07 '24 08:10 uiolee