ssh 到同一网络中的远程电脑 - 权限被拒绝(公钥) [英] ssh to remote pc in the same network - Permission denied (publickey)
问题描述
我正在尝试在远程服务器上安装 git,这些是那台电脑的详细信息
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
而且我已经安装了 openssh 并且 ssh 的状态是这个
and I have install both openssh and the status of the ssh is this
ssh start/running, process 756
我正在尝试从本地电脑 ssh 到那台电脑,这些是我本地的详细信息
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
我可以 ping 到 192.168.1.7
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.
我已经生成了存储在 /home/rashendra/.ssh
中的 rsa 公钥/私钥
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
之后我将id_rsa.pub
的内容复制到远程电脑的.ssh
中的authorized_keys
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
这是我创建的 git 用户的 .ssh
.
所以,现在我正在尝试使用
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
但出现以下错误:
rashendra@rashendra:~/.ssh$ ssh git@192.168.1.7
Permission denied (publickey).
请指教如何解决.因为我需要在这个远程服务器上安装 git 并进一步维护.
Please advice how to resolve. As I need to install git on this remote server and maintain further.
推荐答案
检查 您的权限:
- 在客户端(
chmod 644 ~/.ssh/id_rsa.pub
) 在服务器端
chmod 700 /home/git/.ssh
chmod 600 /home/git/.ssh/authorized_keys
然后,如果还是不行,检查输出:
Then, if it is still not working, check the output of:
- 在客户端,一个
ssh -Tvvv git@192.168.1.7
- 在服务器端,调试 ssh 守护进程会话 (
/usr/sbin/sshd -d
):参见 这个答案.
- 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.
这篇关于ssh 到同一网络中的远程电脑 - 权限被拒绝(公钥)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!