Most solutions I found are about cloning from a GitHub or a Gitlab third-party host. I would like to clone the repository from my server at home via SSH. I kept on getting the error below.
Here are some contexts:
- I'm able to SSH and access those directories normally
- Git is initialized inside the test folder
SSH Host Config
Host my-server
HostName my-server.domain.com
Port 222
Output
$ git clone my-server:mnt/path/directory/test/test.git
Cloning into 'test'...
[email protected]'s password:
fatal: 'mnt/path/directory/test/test.git' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
$ git clone ssh://my-server:mnt/path/directory/test/test.git
Cloning into 'test'...
[email protected]'s password:
fatal: 'mnt/path/directory/test/test.git' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
$ git clone ssh://my-server:222/mnt/path/directory/test/test.git
Cloning into 'test'...
[email protected]'s
fatal: 'mnt/path/directory/test/test.git' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
$ pwd
/mnt/path/directory/test
$ ls -lah
total 12K
drwxr-xr-x. 3 username username 4.0K Feb 27 17:03 .
drwxr-xr-x. 7 username username 4.0K Feb 27 17:03 ..
drwxr-xr-x. 8 username username 4.0K Feb 27 18:32 .git
-rw-r--r--. 1 username username 0 Feb 27 17:03 test.txt
Update #1
The answer below is the solution but I had to use a different port number for the SSH session as mine is not set to the default port.
$ git clone ssh://[email protected]:222:mnt/path/directory/test
Cloning into 'test'...
[email protected]'s password:
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
I also included the username in the ~/.ssh/config and it worked as well.
$ cat ~/.ssh/config
Host my-server
HostName my-server.domain.com
User username
Port 222
$ git clone my-server:/mnt/path/directory/test
Cloning into 'test'...
[email protected]'s password:
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
Two things come to mind here:
git clone username@my-server:/mnt/path/directory/test) or in your~/.ssh/config(parameter in that file isUser username; updated command would begit clone my-server:/mnt/path/directory/test).pwdandlsoutput together suggest that you're using the wrong path in your clone command -/mnt/path/directory/test/test.gitdoesn't exist, but/mnt/path/directory/testdoes. Note that the absolute path is necessary if the repo isn't in~username, and that the colon doesn't separate hostname from path in the URL-style format (git clone ssh://username@my-server/mnt/path/directory/test).