Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
766 views
in Technique[技术] by (71.8m points)

git - ssh to remote pc in the same network - Permission denied (publickey)

I am trying to install git on a remote server and these are the details of that pc

IP 192.168.1.7 
Ubuntu version 12.04 32 bit 

and I have install both openssh and the status of the ssh is this

ssh start/running, process 756

And I am trying to ssh to that pc from local pc and these are the details of my local

IP 192.168.1.4
Ubuntu version 12.04 64 bit

I have ping to the 192.168.1.7

rashendra@rashendra:~$ ping 192.168.1.7
PING 192.168.1.7 (192.168.1.7) 56(84) bytes of data.
64 bytes from 192.168.1.7: icmp_req=1 ttl=64 time=0.918 ms
64 bytes from 192.168.1.7: icmp_req=2 ttl=64 time=1.02 ms
64 bytes from 192.168.1.7: icmp_req=3 ttl=64 time=3.78 ms
^C
--- 192.168.1.7 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.918/1.908/3.782/1.326 ms

which means I can connect to that pc , and the connectivity is alive.

I have generate the rsa public/private key which are stored in the /home/rashendra/.ssh

rashendra@rashendra:~/.ssh$ ll

total 20
drwxrwxrwx  2 rashendra rashendra 4096 Nov 17 11:37 ./
drwxr-xr-x 47 rashendra rashendra 4096 Nov 17 08:35 ../
-rw-------  1 rashendra rashendra 1679 Nov 17 10:57 id_rsa
-rwxrwxrwx  1 rashendra rashendra  401 Nov 17 10:57 id_rsa.pub*
-rw-r--r--  1 rashendra rashendra  444 Nov 17 11:45 known_hosts

After that I copied the content of the id_rsa.pub to the authorized_keys in the .ssh of the remote pc

cat /tmp/id_rsa.pub >> ~/.ssh/authorized_keys

This is the .ssh of the git user which I created.
So, now I am trying to connect to the remote pc using

ssh git@192.168.1.7 

yet gives the following error:

rashendra@rashendra:~/.ssh$ ssh git@192.168.1.7

Permission denied (publickey).

Please advice how to resolve. As I need to install git on this remote server and maintain further.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Check your permissions:

  • on the client side (chmod 644 ~/.ssh/id_rsa.pub)
  • on the server side

    chmod 700 /home/git/.ssh
    chmod 600 /home/git/.ssh/authorized_keys
    

Then, if it is still not working, check the output of:

  • on the client side, a ssh -Tvvv git@192.168.1.7
  • on the server side, a debug ssh daemon session (/usr/sbin/sshd -d): see this answer.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...