V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
vitozhang
V2EX  ›  程序员

求助 SSH -vT [email protected] 命令报错

  •  
  •   vitozhang · 2014-11-20 19:00:33 +08:00 · 4882 次点击
    这是一个创建于 3435 天前的主题,其中的信息可能已经有所发展或是发生改变。
    在使用ssh命令测试能否登陆github服务器的时候出现Permission deny,麻烦各位给分析分析是啥原因
    OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
    debug1: Connecting to github.com [192.30.252.130] port 22.
    debug1: Connection established.
    debug1: identity file /.ssh/identity type -1
    debug1: identity file /.ssh/id_rsa type -1
    debug1: identity file /.ssh/id_dsa type -1
    debug1: Remote protocol version 2.0, remote software version libssh-0.6.0
    debug1: no match: libssh-0.6.0
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_4.6
    debug1: SSH2_MSG_KEXINIT sent
    debug1: SSH2_MSG_KEXINIT received
    debug1: kex: server->client aes128-cbc hmac-sha1 none
    debug1: kex: client->server aes128-cbc hmac-sha1 none
    debug1: sending SSH2_MSG_KEXDH_INIT
    debug1: expecting SSH2_MSG_KEXDH_REPLY
    debug1: Host 'github.com' is known and matches the RSA host key.
    debug1: Found key in /.ssh/known_hosts:1
    Warning: Permanently added the RSA host key for IP address '192.30.252.130' to t
    he list of known hosts.
    debug1: ssh_rsa_verify: signature correct
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug1: SSH2_MSG_NEWKEYS received
    debug1: SSH2_MSG_SERVICE_REQUEST sent
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug1: Authentications that can continue: publickey
    debug1: Next authentication method: publickey
    debug1: Trying private key: /.ssh/identity
    debug1: Trying private key: /.ssh/id_rsa
    debug1: Trying private key: /.ssh/id_dsa
    debug1: No more authentication methods to try.
    Permission denied (publickey).
    10 条回复    2014-11-21 13:29:35 +08:00
    paulw54jrn
        1
    paulw54jrn  
       2014-11-20 19:04:42 +08:00
    找不到private key..

    把private key命名为id_rsa, 放在$HOME/.ssh/试一试
    vitozhang
        2
    vitozhang  
    OP
       2014-11-20 19:05:37 +08:00
    初步确定问题出在
    debug1: identity file /.ssh/identity type -1
    debug1: identity file /.ssh/id_rsa type -1
    debug1: identity file /.ssh/id_dsa type -1
    系统找不到路径 /.ssh/
    这是什么原因呢
    vitozhang
        3
    vitozhang  
    OP
       2014-11-20 19:06:48 +08:00
    @paulw54jrn 忘了跟你说了,我的是win8系统,private key已经放到 用户名/.ssh 目录了
    paulw54jrn
        4
    paulw54jrn  
       2014-11-20 19:11:34 +08:00
    @vitozhang
    Windows下不熟悉.. 你是在Cygwin里面ssh的妈?
    paulw54jrn
        5
    paulw54jrn  
       2014-11-20 19:13:12 +08:00
    根据http://weka.wikispaces.com/Where+is+my+home+directory+located%3F

    on Windows, open a command-prompt and type the following command
    echo %USERPROFILE%
    on Cygwin, open a bash and type the following command
    echo $USERPROFILE

    如果是Cygwin的话, 放在 $USERPROFILE/.ssh/ 试试
    aa65535
        6
    aa65535  
       2014-11-20 19:37:01 +08:00
    到 git 安装目录下去找 ssh_config 这个文件(一般是 /etc/ssh 下面),改成
    IdentityFile=~/.ssh/id_rsa
    注意有个 ~
    Ge4Los
        7
    Ge4Los  
       2014-11-20 20:28:36 +08:00
    如果用cygwin的话, 先要在环境变量里面先定义下HOME
    然后把id_rsa 放在 ~/.ssh/ 的目录下
    vitozhang
        8
    vitozhang  
    OP
       2014-11-21 09:54:28 +08:00
    @paulw54jrn

    @aa65535

    @Ge4Los
    我使用的MinGW,不过跟这个没关系,Git安装目录自带了个ssh以及.ssh目录,我把系统用户名目录下的.ssh 的内容拷贝到Git安装目录下的.ssh中就可以了。不过我还是没找到ssh_config文件,不知道该怎么设置ssh命令默认的private key的存放位置。
    aa65535
        9
    aa65535  
       2014-11-21 10:37:12 +08:00
    @vitozhang Ctrl + F 搜索一下,一般是在 Git 安装目录 下的 etc/ssh 中,或者 MinGW 下的 etc/ssh 中,没有可以新建一个。
    Host *
      StrictHostKeyChecking no
      UserKnownHostsFile=/dev/null
      IdentityFile=~/.ssh/id_rsa

    可以在 http://git-scm.com/downloads 下载一个, 也是 MinGW 的。
    vitozhang
        10
    vitozhang  
    OP
       2014-11-21 13:29:35 +08:00
    @aa65535 在Git安装目录下的etc/ssh目录中添加了ssh_config文件, 并添为所有Host添加IdentityFile=~/.ssh/id_rsa
    但ssh依然将路径解释为 /.ssh/id_rsa,完全忽略了~。
    添加环境变量 HOME,设置为C:/Users/myname,然后将设置身份文件为IdentityFile=$HOME/.ssh/id_rsa发现奏效。另外,如果发现直接设置绝对路径/c/Users/myname/.ssh/id_rsa也是可以的。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3268 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 12:51 · PVG 20:51 · LAX 05:51 · JFK 08:51
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.