SSH Public Key
SSH public keys are used for Git authentication. After configuration, you can clone and push model repositories over SSH without entering an access token.
Prerequisites
- A valid MatrixHub account with access to the target model repository, for example
my-matrixhub-project/test-mn. - Git installed locally. Install Git LFS as well if the repository contains large model files.
- A MatrixHub SSH endpoint exposed by Docker Compose or Helm.
View Existing SSH Keys
Before generating a new SSH key, check if you need to use an existing SSH key stored in the root directory of the local user. For Linux and Mac, use the following command to view existing public keys. Windows users can use the following command in WSL (requires Windows 10 or above) or Git Bash to view the generated public keys.
-
ED25519 Algorithm:
cat ~/.ssh/id_ed25519.pub -
RSA Algorithm:
cat ~/.ssh/id_rsa.pub
If a long string starting with ssh-ed25519 or ssh-rsa is returned, it means that a local public key already exists. You can skip Generate SSH Key and proceed directly to Copy the Public Key.
Generate SSH Key
If you cannot view the existing SSH key, it means that there is no available SSH key locally and a new SSH key needs to be generated. Follow these steps:
-
Access the terminal (Windows users use WSL or Git Bash), and run
ssh-keygen -t. -
Enter the key algorithm type and an optional comment.
The comment will appear in the .pub file and can generally use the email address as the comment content.
-
To generate a key pair based on the
ED25519algorithm, use the following command:ssh-keygen -t ed25519 -C "<comment>" -
To generate a key pair based on the
RSAalgorithm, use the following command:ssh-keygen -t rsa -C "<comment>"
-
-
Press Enter to choose the SSH key generation path.
Taking the ED25519 algorithm as an example, the default path is as follows:
Generating public/private ed25519 key pair.Enter file in which to save the key (/home/user/.ssh/id_ed25519):The default key generation path is
/home/user/.ssh/id_ed25519, and the corresponding public key is/home/user/.ssh/id_ed25519.pub. -
Set a passphrase for the key.
Enter passphrase (empty for no passphrase):Enter same passphrase again:The passphrase is empty by default, and you can choose to use a passphrase to protect the private key file. If you do not want to enter a passphrase every time you access the repository using the SSH protocol, you can enter an empty passphrase when creating the key.
-
Press Enter to complete the key pair creation.
Copy the Public Key
In addition to manually copying the generated public key information printed on the command line, you can use the following commands to copy the public key to the clipboard, depending on your operating system.
-
cat ~/.ssh/id_ed25519.pub | clip
-
Mac:
tr -d '\n'< ~/.ssh/id_ed25519.pub | pbcopy -
GNU/Linux (requires xclip):
xclip -sel clip < ~/.ssh/id_ed25519.pub
Set the Public Key on MatrixHub
-
Log in to the MatrixHub UI page and select Profile -> SSH Public Key -> Import SSH Public Key.
-
Fill the required information in the pop-up window and click Confirm.
Use the SSH Public Key
The SSH repository path is <project>/<model>.git. Use the endpoint that matches your deployment.
Docker Compose
Docker Compose exposes the SSH service on port 2222 by default. Replace <matrixhub-host> with the IP address or hostname of the machine running MatrixHub:
git clone -c core.sshCommand="ssh -p 2222" git@<matrixhub-host>:my-matrixhub-project/test-mn.git
If you set MATRIXHUB_SSH_PORT when starting MatrixHub, use that port instead of 2222.
Helm
For a Helm deployment exposed with the default NodePort settings, use a Kubernetes node IP and port 30022:
git clone -c core.sshCommand="ssh -p 30022" git@<node-ip>:my-matrixhub-project/test-mn.git
Find a node IP with kubectl get nodes -o wide. If you changed apiserver.service.sshNodePort, use the configured port instead of 30022.
Optional: Configure SSH for Long-Term Use
If you use MatrixHub frequently, add an alias to ~/.ssh/config and use the SSH port for your deployment (2222 for Docker Compose or 30022 for the default Helm NodePort):
Host matrixhub
HostName <matrixhub-host-or-node-ip>
Port <ssh-port>
User git
You can then clone repositories with a shorter command:
git clone matrixhub:my-matrixhub-project/test-mn.git
After cloning, use standard Git commands to commit and push changes:
cd test-mn
git add .
git commit -m "Update model"
git push