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

求助:私有域名,固定公网 ip,如何设置可以通过 ssh 访问?

  •  
  •   zeroze · 2018-10-15 16:54:28 +08:00 · 5295 次点击
    这是一个创建于 2013 天前的主题,其中的信息可能已经有所发展或是发生改变。

    各位大佬萌新求助!!

    自购 vultr,ip:1.2.3.4

    有 namecheap 域名:abc.org

    其中以有 A 类解析到 1.2.3.4,我自建的 bottle 服务是可以通过 http://abc.org:8080 访问的

    但是我 ssh -p 22 [email protected] 没有反应

    请问想通过 ssh [email protected] 的方式登录 VPS 请问大概需要怎么操作?

    19 条回复    2018-10-16 09:59:52 +08:00
    CitizenR
        1
    CitizenR  
       2018-10-15 17:13:40 +08:00 via iPhone   ❤️ 2
    我觉得是不是服务器 ssh 服务禁止远程以 root 身份登陆,或者 ssh 服务换个端口。
    MaxTan
        2
    MaxTan  
       2018-10-15 17:18:15 +08:00   ❤️ 1
    改 host
    boris1993
        3
    boris1993  
       2018-10-15 17:18:32 +08:00 via Android   ❤️ 1
    首先拿普通用户登录试试
    其次永远不要允许 root 远程登录
    abclearner
        4
    abclearner  
       2018-10-15 17:19:35 +08:00   ❤️ 1
    试下用 IP 地址登录 ssh [email protected]
    或者 vultr 后台 console 看看什么情况
    abclearner
        5
    abclearner  
       2018-10-15 17:20:47 +08:00
    上面打错了,ssh [email protected]
    zeroze
        6
    zeroze  
    OP
       2018-10-15 17:33:43 +08:00
    @CitizenR vultr 可以直接 ssh root@hostip 登录的感觉不是权限的问题。
    zeroze
        7
    zeroze  
    OP
       2018-10-15 17:34:20 +08:00
    @abclearner ok 的可以进 shell
    zeroze
        8
    zeroze  
    OP
       2018-10-15 17:34:38 +08:00
    @boris1993 感谢提醒主要是试一下
    xmbaozi
        9
    xmbaozi  
       2018-10-15 17:36:16 +08:00   ❤️ 1
    ssh [email protected] -v
    看看报什么错误
    zeroze
        10
    zeroze  
    OP
       2018-10-15 17:36:55 +08:00
    @MaxTan 好主意,但是我想知道为什么现在这个方法不行,我知道 ddns 比如蒲公英都是可以的,我这个 ip 是静态的应该没问题啊。
    zeroze
        11
    zeroze  
    OP
       2018-10-15 17:45:38 +08:00
    @xmbaozi
    OpenSSH_7.7p1, LibreSSL 2.7.3
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 48: Applying options for *
    debug1: Connecting to abc.org port 22.
    debug1: Connection established.
    debug1: identity file /Users/johndoe/.ssh/id_rsa type 0
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/johndoe/.ssh/id_rsa-cert type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/johndoe/.ssh/id_dsa type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/johndoe/.ssh/id_dsa-cert type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/johndoe/.ssh/id_ecdsa type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/johndoe/.ssh/id_ecdsa-cert type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/johndoe/.ssh/id_ed25519 type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/johndoe/.ssh/id_ed25519-cert type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/johndoe/.ssh/id_xmss type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/johndoe/.ssh/id_xmss-cert type -1
    debug1: Local version string SSH-2.0-OpenSSH_7.7
    zeroze
        12
    zeroze  
    OP
       2018-10-15 17:46:13 +08:00
    ssh_exchange_identification: Connection closed by remote host
    CitizenR
        13
    CitizenR  
       2018-10-15 18:58:36 +08:00
    @zeroze 看#11 楼报错,貌似是免密登录失败,可以正常连接的。
    zeroze
        14
    zeroze  
    OP
       2018-10-15 22:22:31 +08:00 via iPhone
    @CitizenR 我没有设置免密登陆,且我 @ip 登陆是需要密码的,是不是可能我 vps,ssh 需要配置一下?
    HannibaI
        15
    HannibaI  
       2018-10-15 22:28:39 +08:00 via iPhone   ❤️ 1
    ssh 没开密码登录
    victor97
        16
    victor97  
       2018-10-15 22:32:58 +08:00 via Android   ❤️ 1
    检查下你 ssh client 的 config 文件,貌似是配置了密钥登录,但找不到密钥文件
    victor97
        17
    victor97  
       2018-10-15 22:36:31 +08:00 via Android
    或者试一试 ssh root:[email protected]
    zeroze
        18
    zeroze  
    OP
       2018-10-16 09:58:35 +08:00
    @victor97
    感谢!
    请问是 vps 上的 ssh_config 是吗,但是为啥不是改 sshd_config 呢?
    是不是
    法一:去掉这项的注释 PasswordAuthentication yes 通过密码登录
    法二:ssh-keygen 生成一个 id_rsa,再通过本地通过 ssh -i id_ras.pub [email protected] 登录 VPS
    附上 ssh_config
    Host *
    # ForwardAgent no
    # ForwardX11 no
    # ForwardX11Trusted yes
    # RhostsRSAAuthentication no
    # RSAAuthentication yes
    # PasswordAuthentication yes
    # HostbasedAuthentication no
    # GSSAPIAuthentication no
    # GSSAPIDelegateCredentials no
    # GSSAPIKeyExchange no
    # GSSAPITrustDNS no
    # BatchMode no
    # CheckHostIP yes
    # AddressFamily any
    # ConnectTimeout 0
    # StrictHostKeyChecking ask
    # IdentityFile ~/.ssh/identity
    # IdentityFile ~/.ssh/id_rsa
    # IdentityFile ~/.ssh/id_dsa
    # IdentityFile ~/.ssh/id_ecdsa
    # IdentityFile ~/.ssh/id_ed25519
    # Port 22
    # Protocol 2
    # Cipher 3des
    # Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
    # MACs hmac-md5,hmac-sha1,[email protected],hmac-ripemd160
    # EscapeChar ~
    # Tunnel no
    # TunnelDevice any:any
    # PermitLocalCommand no
    # VisualHostKey no
    # ProxyCommand ssh -q -W %h:%p gateway.example.com
    # RekeyLimit 1G 1h
    SendEnv LANG LC_*
    HashKnownHosts yes
    GSSAPIAuthentication yes
    zeroze
        19
    zeroze  
    OP
       2018-10-16 09:59:52 +08:00
    @HannibaI 感谢感觉就是这个问题
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3932 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 10:16 · PVG 18:16 · LAX 03:16 · JFK 06:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.