Article Directory
Gogs configuration ssh
Description, the operating version is gogs_0.12.1_windows_amd64
.
Operation is preferably Git Bash
performed before installing Gogs , run time ./gogs web
to generate a configuration file, again with reference to modify the configuration described herein.
1.gogs custom configuration file confapp.ini configuration
Win10 is used here START_SSH_SERVER = true
.
BRAND_NAME = GogsTest
RUN_USER = MagicBook
RUN_MODE = prod
[database]
TYPE = mysql
HOST = 127.0.0.1:3306
NAME = gogstest
USER = 你的数据库用户名
PASSWORD = 你的数据库密码
SSL_MODE = disable
PATH = D:\TDDOWNLOAD\gogs_0.12.1_windows_amd65\gogs\data\gogs.db
[repository]
ROOT = D:/TDDOWNLOAD/gogs_0.12.1_windows_amd65/repo
[server]
DOMAIN = gogstest.cc
HTTP_PORT = 3000
EXTERNAL_URL = http://gogstest.cc:3000/
DISABLE_SSH = false
SSH_PORT = 3022
START_SSH_SERVER = true
OFFLINE_MODE = false
[mailer]
ENABLED = false
[service]
REGISTER_EMAIL_CONFIRM = false
ENABLE_NOTIFY_MAIL = false
DISABLE_REGISTRATION = false
ENABLE_CAPTCHA = true
REQUIRE_SIGNIN_VIEW = false
[picture]
DISABLE_GRAVATAR = false
ENABLE_FEDERATED_AVATAR = false
[session]
PROVIDER = file
[log]
MODE = file
LEVEL = Info
ROOT_PATH = D:/TDDOWNLOAD/gogs_0.12.1_windows_amd65/gogs/log
[security]
INSTALL_LOCK = true
SECRET_KEY = SBG5Ep2rvkb3Fyr
2. Configure hosts
Modify the C:\Windows\System32\drivers\etc\hosts
file, it can be configured as follows:
# Gogs local HTTPd
127.0.0.1 gogstest.cc
3. Database
As shown below:
4. Click the configuration of the ssh folder
4.1 Generate private key and public key
Use the ssh-keygen -t rsa -C "你的邮箱" -f /c/Users/MagicBook/.ssh/gitgogstest_id_rsa
command and hit enter four times to get the gitgogstest_id_rsa
private key and gitgogstest_id_rsa.pub
public key. You can also configure several more, and different websites use different private and public keys. The generated command is as follows:
ssh-keygen -t rsa -C "你的邮箱" -f /c/Users/MagicBook/.ssh/gitee_id_rsa
ssh-keygen -t rsa -C "你的邮箱" -f /c/Users/MagicBook/.ssh/github_id_rsa
ssh-keygen -t rsa -C "你的邮箱" -f /c/Users/MagicBook/.ssh/gitlab_id_rsa
ssh-keygen -t rsa -C "你的邮箱" -f /c/Users/MagicBook/.ssh/gitgogs_id_rsa
ssh-keygen -t rsa -C "你的邮箱" -f /c/Users/MagicBook/.ssh/gitgogstest_id_rsa
The results are as follows:
4.2 Configure config
# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile /c/Users/MagicBook/.ssh/gitee_id_rsa
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile /c/Users/MagicBook/.ssh/github_id_rsa
# Gitlab
Host gitlab.com
HostName gitlab.com
PreferredAuthentications publickey
IdentityFile /c/Users/MagicBook/.ssh/gitlab_id_rsa
# Gogs
Host gogs.cc
HostName gogs.cc
PreferredAuthentications publickey
IdentityFile /c/Users/MagicBook/.ssh/gitgogs_id_rsa
# GogsTest
Host gogstest.cc
HostName gogstest.cc
PreferredAuthentications publickey
IdentityFile /c/Users/MagicBook/.ssh/gitgogstest_id_rsa
4.3 Upload public key
The URL should be http://gogstest.cc:3000/user/settings/ssh
. Copy gitgogstest_id_rsa.pub
the content of the public key and upload it.
5. Test
Create a new warehouse, copy the ssh address, download, upload. See if the secret free is successful.
other
Win10 git ssh configuration original text
When there are multiple git accounts, such as:
a. A gitee, used for the company's internal work development;
b. A github, used for some development activities;
Solution
- Generate an SSH-Key for the company
$ ssh-keygen -t rsa -C '[email protected]' -f ~/.ssh/gitee_id_rsa
- Generate an SSH-Key for github
$ ssh-keygen -t rsa -C '[email protected]' -f ~/.ssh/github_id_rsa
- Create a new config file in the ~/.ssh directory and add the following content (where Host and HostName fill in the domain name of the git server, and IdentityFile specifies the path of the private key)
# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitee_id_rsa
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_id_rsa
4. Use the ssh command to test separately
$ ssh -T [email protected]
$ ssh -T [email protected]
Take gitee as an example, if successful, it will return to the following figure