SSH在远程PC在同一网络 - 权限被拒绝(公钥) [英] ssh to remote pc in the same network - Permission denied (publickey)

查看:414
本文介绍了SSH在远程PC在同一网络 - 权限被拒绝(公钥)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在远程服务器上安装git,这些是该pc的详细信息

  IP 192.168.1.7 
Ubuntu版本12.04 32位

我安装了两个openssh,并且ssh的状态为这

  ssh启动/运行,进程756 

我试图从本地电脑ssh到那台电脑,这些是我本地的详细信息

  IP 192.168.1.4 
Ubuntu版本12.04 64位

我有ping到192.168.1.7

  rashendra @ rashendra:〜$ ping 192.168.1.7 
PING 192.168.1.7(192.168。 1.7)56(84)字节的数据。
来自192.168.1.7的64字节:icmp_req = 1 ttl = 64时间= 0.918 ms
来自192.168.1.7的64字节:icmp_req = 2 ttl = 64 time = 1.02 ms
从192.168开始的64字节.1.7:icmp_req = 3 ttl = 64时间= 3.78毫秒
^ C
--- 192.168.1.7 ping统计信息---
传输3个数据包,接收3个数据包,丢失0%时间2000ms
rtt min / avg / max / mdev = 0.918 / 1.908 / 3.782 / 1.326 ms



<这意味着我可以连接到那台电脑,并且连接是活着的。



我已经生成了存储在 /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 的内容复制到 authorized_keys 在远程PC的 .ssh

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

这是 .ssh 我创建的git用户。

所以,现在我试图用

  ssh git@192.168.1.7 

还有以下错误:

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

权限被拒绝(publickey)。

请咨询如何解决。
因为我需要在这个远程服务器上安装git并进一步维护。

解决方案

检查您的权限




  • chmod 644〜/ .ssh / id_rsa.pub

  • 服务器端

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



    b $ b

    • 在客户端, ssh -Tvvv git@192.168.1.7

    • 在服务器端,一个调试ssh守护进程会话( / usr / sbin / sshd -d ):参见这个答案


    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.

    解决方案

    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.

    这篇关于SSH在远程PC在同一网络 - 权限被拒绝(公钥)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆