【Ubuntu-18.04】git出现Failed to add the host to the list of known hosts (/home/w1804/.ssh/known_hosts

问题log

w1804@w1804-virtual-machine:~$ git clone ssh://xxxxxxxxxx
Cloning into 'xxxxxxxxxx'...
The authenticity of host '[xxx.xxxx.com]:29418 ([xxx.xxx.xxx.xxx]:29418)' can't be established.
RSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/w1804/.ssh/known_hosts).
xxxx.xxxx.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

问题原因

      这是由于.ssh目录没有给到用户权限导致,git clone时无法修改known_hosts文件,添加信任主机信息

解决方案

切换为root账户,然后执行以下指令

chmod 777 /home/w1804/.ssh
chmod 777 /home/w1804/.ssh/*

退出root,直接clone即可
 

你可能感兴趣的:(ubuntu,ubuntu,linux,运维)