Why can't I use github as a normal user?
漂亮男人
漂亮男人 2017-05-02 09:45:47
0
1
627

As the root user, you can successfully use git to push and pull without a password.
New project name: newstart.
The following are the settings for root user.

su root
ssh-keygen -t rsa -f /root/.ssh/id_rsa.github -P ''

Paste id_rsa.github.pub to the ssh key’s githhub web page.

git config --global user.name "someone"
git config --global user.email  "sbd@gmail.com"
git config remote.origin.url git+ssh://git@github.com/someone/newstart.git
ssh -T git@github.com
git clone  git+ssh://git@github.com/someone/newstart.git /tmp/newstart

Cloning into '/tmp/newstart'...

The root user can be used successfully without any problems.

Now set up a normal user debian8 and all the settings just now will be reset.

su debian8
ssh-keygen -t rsa -f /home/debian8/.ssh/id_rsa.github -P ''

Paste this key id_rsa.github.pub to the ssh key in githhub web page.

git config --global user.name "someone"
git config --global user.email  "sbd@gmail.com"
git config remote.origin.url git+ssh://git@github.com/someone/newstart.git
#注意,在普通用户下,无法使用config.
error: could not lock config file .git/config: Permission denied
sudo git config remote.origin.url git+ssh://git@github.com/someone/newstart.git   
ssh -T git@github.com
Permission denied (publickey).
我通过-i 参数,可以让这个普通用户连接上github.
ssh -i ./id_rsa.github.pub  -vT git@github.com
You've successfully authenticated, but GitHub does not provide shell access.
可惜,连接上没有用,无法clone.

git clone  git+ssh://git@github.com/someone/newstart.git /tmp/newstart
Cloning into '/tmp/newstart'...
Permission denied (publickey).
fatal: Could not read from remote repository.
 Please make sure you have the correct access rights  and the repository exists.

How can I modify my steps for ordinary users? What causes this to happen?

漂亮男人
漂亮男人

reply all(1)
我想大声告诉你

It is recommended to check your HOME environment variable. It may be that you have modified it before, causing git to not find .gitconfig了;另外,你可以检查一下你的用户主目录下有没有.gitconfig. Use it in your user directory:

ls -a | grep .gitconfig

If it shows no .gitconfig,说明很可能是因为git在当前用户的主目录下找不到gitconfig.

or you can use locate命令搜索一下.gitconfig,

locate .gitconfig

If unfortunately, you cannot find it using locate, then use updatedbto update the locate database. If your hard drive is fast enough, it can be completed quickly.

sudo updatedb

Of course you can also use the find command, but the speed is slower:

sudo find / -name .gitconfig

After the above operation has results, take a look at the .gitconfig文件的所在路径是否是echo $HOME results. If not, it means that the problem is indeed your $HOME environment variable. It is recommended to reset it to the path of your current user's home directory.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template