Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hexo d must enter pwd | hexo deploy的时候一直需要输入密码 #175

Closed
macreee opened this issue Mar 10, 2020 · 12 comments · Fixed by #351
Closed

hexo d must enter pwd | hexo deploy的时候一直需要输入密码 #175

macreee opened this issue Mar 10, 2020 · 12 comments · Fixed by #351

Comments

@macreee
Copy link

macreee commented Mar 10, 2020

预期目标

  • hexo d 不需要输入密码

Expected behavior

  • hexo d does not require a password

遇到的bug

  • 我的目录是/home/git/hexo.git

  • 我已经在./git.ssh/authorized_keys中设置了git用户的公钥

    但依旧在deploy的时候需要输入密码

    image

    因为找不到问题所在,我索性也在hexo.git/.ssh/authorized_keys中也复制了一份公钥
    image

Actual behavior

  • My directory is: /home/git/hexo.git

  • I have set the user git's publickey in ./git.ssh/authorized_keys

    but I still need password when I hexo d

    image

    I could n’t find the problem, so I simply copied a public key in
    hexo.git/.ssh/authorized_keys
    image

Environment & Settings

Node.js & npm version

v12.16.1

Your site _config.yml (Optional)

# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: XX
subtitle: ''
description: ''
keywords:
author: MaCree
language: zh-CN
timezone: ''

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: https://xxx.cn
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:
pretty_urls:
  trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
  trailing_html: true # Set to false to remove trailing '.html' from permalinks

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:

# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link:
  enable: true # Open external links in new tab
  field: site # Apply to the whole site
  exclude: ''
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
  enable: false
  line_number: true
  auto_detect: false
  tab_replace: ''
  wrap: true
  hljs: false

# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
  path: ''
  per_page: 10
  order_by: -date

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Metadata elements
## https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
meta_generator: true

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss
## Use post's date for updated date unless set in front-matter
use_date_for_updated: false

# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page

# Include / Exclude file(s)
## include:/exclude: options only apply to the 'source/' folder
include:
exclude:
ignore:

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: fluid

# Deployment
## Docs: https://hexo.io/docs/deployment.html(这个目录下已经没有文档了。。。)
deploy:
  type: git
  repo: git@1.2.3.4:/home/git/hexo.git(不是真实地址但是格式一致/just a example)
  branch: master

Hexo and Plugin version(npm ls --depth 0)

hexo-site@0.0.0 /home/macreeblog
├── hexo@4.2.0
├── hexo-deployer-git@2.1.0
├── hexo-generator-archive@1.0.0
├── hexo-generator-category@1.0.0
├── hexo-generator-index@1.0.0
├── hexo-generator-tag@1.0.0
├── hexo-render-pug@2.1.4
├── hexo-renderer-ejs@1.0.0
├── hexo-renderer-marked@2.0.0
├── hexo-renderer-stylus@1.1.0
└── hexo-server@1.0.0

Your package.json package.json

{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "build": "hexo generate",
    "clean": "hexo clean",
    "deploy": "hexo deploy",
    "server": "hexo server"
  },
  "hexo": {
    "version": "4.2.0"
  },
  "dependencies": {
    "hexo": "^4.0.0",
    "hexo-deployer-git": "^2.1.0",
    "hexo-generator-archive": "^1.0.0",
    "hexo-generator-category": "^1.0.0",
    "hexo-generator-index": "^1.0.0",
    "hexo-generator-tag": "^1.0.0",
    "hexo-render-pug": "^2.1.4",
    "hexo-renderer-ejs": "^1.0.0",
    "hexo-renderer-marked": "^2.0.0",
    "hexo-renderer-stylus": "^1.1.0",
    "hexo-server": "^1.0.0"
  }
}

Others

  • 目前手动输入密码同步正常所以就没放themes/_config.yml
  • Entering the password manually is normal
    so themes/_config.yml is not necessary
@HoshinoTouko
Copy link

执行一下 $ ssh-agent -s 看看

@jiangtj
Copy link
Member

jiangtj commented Mar 15, 2020

ssh秘钥生成的时候,有输密码步骤,不填不用,填了之后每次都要输😂

@macreee
Copy link
Author

macreee commented Mar 16, 2020

执行一下 $ ssh-agent -s 看看
输出是这个:
SSH_AUTH_SOCK=/tmp/ssh-WHGd29QdyaLb/agent.19287; export SSH_AUTH_SOCK;
SSH_AGENT_PID=19288; export SSH_AGENT_PID;
echo Agent pid 19288;

@macreee
Copy link
Author

macreee commented Mar 16, 2020

ssh秘钥生成的时候,有输密码步骤,不填不用,填了之后每次都要输😂

那我尝试重新生成一下试试。Linux比较萌新不太懂这些,谢谢了。
——————
刚刚重新生成了一下还是不行。好蛋疼

@stevenjoezhang stevenjoezhang transferred this issue from hexojs/hexo Mar 30, 2020
@Bonsailinse
Copy link

I have the same problem, neither running an ssh-agent nor using a token (I tried both entering it as plain text and as a env) let me deploy without the password prompt.
$ ssh -T git@github.com gave the expected result, also other instances using the ssh-agent are working fine.

OSX 10.15.5
node v14.3.0
npm 6.14.5

_config.yml:

## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: 'git'
  repo: https://github.com/Bonsailinse/bonsailinse.github.io
  branch: master
  name: Bonsailinse
  email: mail@bonsailinse.net
  token: $HEXO_GITHUB_TOKEN

Everything else is untouched, also tried without and with plaintext token

Hexo and Plugin version

hexo-site@0.0.0 /Users/bonsailinse/bonsailinse.github.io
├── hexo@4.2.1
├── hexo-deployer-git@2.1.0
├── hexo-generator-archive@1.0.0
├── hexo-generator-category@1.0.0
├── hexo-generator-index@1.0.0
├── hexo-generator-searchdb@1.3.0
├── hexo-generator-tag@1.0.0
├── hexo-renderer-ejs@1.0.0
├── hexo-renderer-marked@2.0.0
├── hexo-renderer-stylus@1.1.0
├── hexo-server@1.0.0
└── hexo-symbols-count-time@0.7.1

package.json:


{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "build": "hexo generate",
    "clean": "hexo clean",
    "deploy": "hexo deploy",
    "server": "hexo server"
  },
  "hexo": {
    "version": "4.2.1"
  },
  "dependencies": {
    "hexo": "^4.2.1",
    "hexo-deployer-git": "^2.1.0",
    "hexo-generator-archive": "^1.0.0",
    "hexo-generator-category": "^1.0.0",
    "hexo-generator-index": "^1.0.0",
    "hexo-generator-searchdb": "^1.3.0",
    "hexo-generator-tag": "^1.0.0",
    "hexo-renderer-ejs": "^1.0.0",
    "hexo-renderer-marked": "^2.0.0",
    "hexo-renderer-stylus": "^1.1.0",
    "hexo-server": "^1.0.0",
    "hexo-symbols-count-time": "^0.7.1"
  }
}

@macreee
Copy link
Author

macreee commented Jun 21, 2020

我有同样的问题,既不运行 ssh 代理,也不使用令牌(我尝试将其输入为纯文本和 env),让我在没有密码提示的情况下进行部署。
给出了预期的结果,使用 ssh 代理的其他实例工作正常。$ ssh -T git@github.com

OSX 10.15.5
节点 v14.3.0
npm 6.14.5

_config.yml:

## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: 'git'
  repo: https://github.com/Bonsailinse/bonsailinse.github.io
  branch: master
  name: Bonsailinse
  email: mail@bonsailinse.net
  token: $HEXO_GITHUB_TOKEN

其他一切都是未触及的,也尝试没有和纯文本令牌

Hexo 和插件版本

hexo-site@0.0.0 /Users/bonsailinse/bonsailinse.github.io
├── hexo@4.2.1
├── hexo-deployer-git@2.1.0
├── hexo-generator-archive@1.0.0
├── hexo-generator-category@1.0.0
├── hexo-generator-index@1.0.0
├── hexo-generator-searchdb@1.3.0
├── hexo-generator-tag@1.0.0
├── hexo-renderer-ejs@1.0.0
├── hexo-renderer-marked@2.0.0
├── hexo-renderer-stylus@1.1.0
├── hexo-server@1.0.0
└── hexo-symbols-count-time@0.7.1

包.json:


{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "build": "hexo generate",
    "clean": "hexo clean",
    "deploy": "hexo deploy",
    "server": "hexo server"
  },
  "hexo": {
    "version": "4.2.1"
  },
  "dependencies": {
    "hexo": "^4.2.1",
    "hexo-deployer-git": "^2.1.0",
    "hexo-generator-archive": "^1.0.0",
    "hexo-generator-category": "^1.0.0",
    "hexo-generator-index": "^1.0.0",
    "hexo-generator-searchdb": "^1.3.0",
    "hexo-generator-tag": "^1.0.0",
    "hexo-renderer-ejs": "^1.0.0",
    "hexo-renderer-marked": "^2.0.0",
    "hexo-renderer-stylus": "^1.1.0",
    "hexo-server": "^1.0.0",
    "hexo-symbols-count-time": "^0.7.1"
  }
}

I'm sorry you encountered the same situation as me, but unfortunately I can't help you because I didn't use github pages to deploy.
I now point the request to the generated static file through nginx, because I found that in the case of a server, only need to generate a static file. There is no need to implement hexo -d..
I searched. The solution seems to be to switch the deploy address to the ssh protocol
such as

deploy:
  type: git
  repo: git@github.com:username/username.github.io.git
  branch: master

Also ask, did you add the private key to github?

@Bonsailinse
Copy link

Thanks for reviewing my case, I could only assume we have the same problem (my chinese is pretty much non-existent).
Yes, I try to use GitHub pages, but this should not make a difference in deploying.
Also yes, I doublechecked my SSH key is added and working.
I will try to change the address, looks like a solution that could work. Unfortunately I'm not in reach of my repo atm, will try it when I'm back home.

@Bonsailinse
Copy link

Nevermind, had a VPN open to my home, changed the address to repo: git@github.com:Bonsailinse/bonsailinse.github.io.git and it worked. Seems like it used the SSH-key and not the token, will check that later.

Thank you very much, you are my hero!

@macreee
Copy link
Author

macreee commented Jun 21, 2020

Nevermind, had a VPN open to my home, changed the address to repo: git@github.com:Bonsailinse/bonsailinse.github.io.git and it worked. Seems like it used the SSH-key and not the token, will check that later.

Thank you very much, you are my hero!

It's good to useful🤣

@MichaelJ9000
Copy link

I encounter this trouble too.

@Gaoustcer
Copy link

我有同样的问题,既不运行 ssh 代理,也不使用令牌(我尝试将其输入为纯文本和 env),让我在没有密码提示的情况下进行部署。
给出了预期的结果,使用 ssh 代理的其他实例工作正常。$ ssh -T git@github.com
OSX 10.15.5
节点 v14.3.0
npm 6.14.5
_config.yml:

## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: 'git'
  repo: https://github.com/Bonsailinse/bonsailinse.github.io
  branch: master
  name: Bonsailinse
  email: mail@bonsailinse.net
  token: $HEXO_GITHUB_TOKEN

其他一切都是未触及的,也尝试没有和纯文本令牌
Hexo 和插件版本

hexo-site@0.0.0 /Users/bonsailinse/bonsailinse.github.io
├── hexo@4.2.1
├── hexo-deployer-git@2.1.0
├── hexo-generator-archive@1.0.0
├── hexo-generator-category@1.0.0
├── hexo-generator-index@1.0.0
├── hexo-generator-searchdb@1.3.0
├── hexo-generator-tag@1.0.0
├── hexo-renderer-ejs@1.0.0
├── hexo-renderer-marked@2.0.0
├── hexo-renderer-stylus@1.1.0
├── hexo-server@1.0.0
└── hexo-symbols-count-time@0.7.1

包.json:


{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "build": "hexo generate",
    "clean": "hexo clean",
    "deploy": "hexo deploy",
    "server": "hexo server"
  },
  "hexo": {
    "version": "4.2.1"
  },
  "dependencies": {
    "hexo": "^4.2.1",
    "hexo-deployer-git": "^2.1.0",
    "hexo-generator-archive": "^1.0.0",
    "hexo-generator-category": "^1.0.0",
    "hexo-generator-index": "^1.0.0",
    "hexo-generator-searchdb": "^1.3.0",
    "hexo-generator-tag": "^1.0.0",
    "hexo-renderer-ejs": "^1.0.0",
    "hexo-renderer-marked": "^2.0.0",
    "hexo-renderer-stylus": "^1.1.0",
    "hexo-server": "^1.0.0",
    "hexo-symbols-count-time": "^0.7.1"
  }
}

I'm sorry you encountered the same situation as me, but unfortunately I can't help you because I didn't use github pages to deploy. I now point the request to the generated static file through nginx, because I found that in the case of a server, only need to generate a static file. There is no need to implement hexo -d.. I searched. The solution seems to be to switch the deploy address to the ssh protocol such as

deploy:
  type: git
  repo: git@github.com:username/username.github.io.git
  branch: master

Also ask, did you add the private key to github?

This solves my problem, I found ssh-key only works for git@ request rather than https

@stevenjoezhang
Copy link
Member

stevenjoezhang commented Mar 31, 2024

I will update the README to recommend users to use the repository link format git@github.com: #351

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants