博客运行问题及解决

好久没有更新博客了,昨天写了点东西,hexo d的时候却出错了,不能部署。今天终于解决了,在这里记录一下。

遇到的第一个问题,hexo d的时候,出现:

fatal: could not read Username for 'https://github.com': Invalid argument
Error: bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.com': Invalid argument

解决方法:

之前在_config.yml中的deploy要改一下,改为:

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

然后重新生成SSH key,并添加到GitHub的账户中,把之前的删掉即可

生成KEY的命令:

$ ssh-keygen -t rsa -C greenovia@qq.com(换成你的邮箱地址)

生成过程中一直回车和yes即可。

最后会在/c/Users/Administrator/.ssh/id_rsa文件中就生成了公钥,即id_rsa.pub中的内容,将公钥添加入GitHub中即可。

之后再次hexo d时,又出现新的问题

Error: Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

发现在/c/Users/Administrator/.ssh/文件夹中没有know_hosts文件,执行

$ ssh git@github.com

我输入这条命令后,文件夹中就会出现know_hosts文件,并且hexo d成功。