Specify Port For Hexo Git Deployment

Usually if you want to deploy your hexo posts with git, you can add the following lines to your _config.yml file:

1
2
3
4
5
6
7
# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy:
type: git
repo: git@example.com:blog.git
branch: master
message:

And hexo would deploy your posts if you run hexo deploy, and it will use port 22 (because git uses ssh or https protocal to access server, and hexo will use git under ssh by default). What if the ssh port of your server is not 22? Say it’s port 20000, what can you do? You can change the contents to the following lines:

1
2
3
4
5
6
7
# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy:
type: git
repo: ssh://git@example.com:20000/home/git/blog.git
branch: master
message:

Run hexo deploy, and it works too. Hooray!

Share