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

vscode SSL 自动登录死活设置不上

  •  
  •   tracker647 · 2022-05-03 15:10:57 +08:00 · 2713 次点击
    这是一个创建于 936 天前的主题,其中的信息可能已经有所发展或是发生改变。

    检查了一遍,自己已经把.ssh/id_rsa.pub 的文件内容导入到服务器的 authorized_keys 里,为此我还重走了一遍教程流程,仍旧连接后提示要密码,搜了下网上的教程说是 /etc/ssh/sshd_config 有部分设置要改,但是 sshd_config 里设置好

    RSAAuthentication yes
    PubkeyAuthentication yes 
    AuthorizedKeysFile      .ssh/authorized_keys .ssh/authorized_keys2 
    

    然后重启 sshd 服务以后还是要密码,已经不知道怎么办了。

    服务器系统是 Ubuntu 20.04, 我用的客户机是 Windows 系统。

    第 1 条附言  ·  2022-05-04 14:45:10 +08:00
    问题解决。

    我把开发机和服务器.ssh 文件下的文件全部删了, 然后按照教程再次让开发机生成了个公钥给服务器的 authorer_key , 应该是 IdentityFile 的问题, 当时我有多弄一个 id_rsa-remote-ssh.pub 的公钥给服务器,换系统的时候只更新了 id_rsa.pub 忘了更新 id_rsa-remote-ssh.pub , 结果导致一直要密码验证,把 IdentityFile 一行删掉就行了。

    出于安全感的考虑没想到坑了自己。。。。
    22 条回复    2022-05-03 23:19:41 +08:00
    461da73c
        1
    461da73c  
       2022-05-03 15:43:51 +08:00   ❤️ 1
    1. 检查 id_rsa 秘钥权限;
    2. 换 ed25519 算法来替代 rsa ;
    lostberryzz
        2
    lostberryzz  
       2022-05-03 15:48:01 +08:00
    别看网上教程瞎改,默认配置就支持密钥登陆,把上面三行都注释 /删掉,恢复默认状态,重启 sshd 服务
    sola97
        3
    sola97  
       2022-05-03 16:00:57 +08:00 via Android
    啥都不用改,用 ssh-copy-id
    thewangcj
        4
    thewangcj  
       2022-05-03 16:04:57 +08:00
    可以用类似这样的命令起一个 sshd:sudo /usr/sbin/sshd -p 端口号 -d
    然后再登录看看报啥错误排查一下(注意下登录时候的端口号)
    tracker647
        5
    tracker647  
    OP
       2022-05-03 16:49:29 +08:00
    @461da73c

    ~/.ssh# ls -ahl
    total 20K
    drwx------ 2 root root 4.0K May 3 16:39 .
    drwx------ 6 root root 4.0K May 3 16:42 ..
    -rw------- 1 root root 1.5K May 3 16:35 authorized_keys
    -rw------- 1 root root 3.4K May 3 14:30 id_rsa-remote-ssh
    -rw-r--r-- 1 root root 754 May 3 14:30 id_rsa-remote-ssh.pub
    tracker647
        6
    tracker647  
    OP
       2022-05-03 16:52:46 +08:00
    @thewangcj 不太懂,不然我日志给你看看

    [16:49:56.260] Log Level: 2
    [16:49:56.261] [email protected]
    [16:49:56.261] win32 x64
    [16:49:56.294] SSH Resolver called for "ssh-remote+7b22686f73744e616d65223a225268696e6f4f53227d", attempt 1
    [16:49:56.294] "remote.SSH.useLocalServer": false
    [16:49:56.295] "remote.SSH.showLoginTerminal": true
    [16:49:56.295] "remote.SSH.remotePlatform": {"RhinoOS":"linux"}
    [16:49:56.295] "remote.SSH.path": undefined
    [16:49:56.295] "remote.SSH.configFile": undefined
    [16:49:56.296] "remote.SSH.useFlock": true
    [16:49:56.296] "remote.SSH.lockfilesInTmp": false
    [16:49:56.296] "remote.SSH.localServerDownload": auto
    [16:49:56.296] "remote.SSH.remoteServerListenOnSocket": false
    [16:49:56.296] "remote.SSH.showLoginTerminal": true
    [16:49:56.297] "remote.SSH.defaultExtensions": []
    [16:49:56.297] "remote.SSH.loglevel": 2
    [16:49:56.297] "remote.SSH.enableDynamicForwarding": true
    [16:49:56.297] "remote.SSH.enableRemoteCommand": false
    [16:49:56.297] "remote.SSH.serverPickPortsFromRange": {}
    [16:49:56.298] "remote.SSH.serverInstallPath": {}
    [16:49:56.301] SSH Resolver called for host: RhinoOS
    [16:49:56.301] Setting up SSH remote "RhinoOS"
    [16:49:56.307] Using commit id "dfd34e8260c270da74b5c2d86d61aee4b6d56977" and quality "stable" for server
    [16:49:56.312] Install and start server if needed
    [16:49:56.346] Checking ssh with "ssh -V"
    [16:49:56.392] > OpenSSH_for_Windows_8.1p1, Libr
    [16:49:56.392] > eSSL 3.0.2

    [16:49:56.399] Running script with connection command: ssh -T -D 1044 "RhinoOS" bash
    [16:49:56.402] Terminal shell path: C:\WINDOWS\System32\cmd.exe
    [16:49:56.740] > ]0;C:\WINDOWS\System32\cmd.exe
    [16:49:56.740] Got some output, clearing connection timeout
    [16:49:56.756] >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    [16:49:57.125] > root@xxxxxxxxxxx's password:
    [16:50:27.234] > root@xxxxxxxxxxx's 's password:
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    [16:50:36.456] >
    [16:50:36.766] > 1bb5fa0390e8: running
    [16:50:36.789] > Acquiring lock on /root/.vscode-server/bin/dfd34e8260c270da74b5c2d86d61aee4b6d56977/vscode-remo
    > te-lock.root.dfd34e8260c270da74b5c2d86d61aee4b6d56977
    [16:50:36.798] > Found existing installation at /root/.vscode-server/bin/dfd34e8260c270da74b5c2d86d61aee4b6d5697
    > 7...
    > Checking /root/.vscode-server/.dfd34e8260c270da74b5c2d86d61aee4b6d56977.log and /root/.vscode-s
    > erver/.dfd34e8260c270da74b5c2d86d61aee4b6d56977.pid for a running server
    > Looking for server with pid: 68202
    [16:50:36.813] > Found running server...
    >
    > *
    > * Reminder: You may only use this software with Visual Studio family products,
    > * as described in the license ( https://go.microsoft.com/fwlink/?linkid=2077057)
    [16:50:36.829] > *
    >
    > Checking server status on port 39375 with wget
    > 1bb5fa0390e8: start
    > SSH_AUTH_SOCK====
    > DISPLAY====
    > webUiAccessToken====
    > listeningOn==39375==
    > osReleaseId==ubuntu==
    > arch==x86_64==
    > tmpDir==/run/user/0==
    [16:50:36.845] >
    > platform==linux==
    > unpackResult====
    [16:50:36.862] >
    > didLocalDownload==0==
    > downloadTime====
    > installTime====
    > extInstallTime====
    > serverStartTime====
    > connectionToken==a11a1aa1-11aa-11a1-1111-1aa1a11a1aa1==
    > 1bb5fa0390e8: end
    [16:50:36.863] Received install output:
    SSH_AUTH_SOCK====
    DISPLAY====
    webUiAccessToken====
    listeningOn==39375==
    osReleaseId==ubuntu==
    arch==x86_64==
    tmpDir==/run/user/0==
    platform==linux==
    unpackResult====
    didLocalDownload==0==
    downloadTime====
    installTime====
    extInstallTime====
    serverStartTime====
    connectionToken==a11a1aa1-11aa-11a1-1111-1aa1a11a1aa1==

    [16:50:36.864] Remote server is listening on 39375
    [16:50:36.864] Parsed server configuration: {"serverConfiguration":{"remoteListeningOn":{"port":39375},"osReleaseId":"ubuntu","arch":"x86_64","webUiAccessToken":"","sshAuthSock":"","display":"","tmpDir":"/run/user/0","platform":"linux","connectionToken":"a11a1aa1-11aa-11a1-1111-1aa1a11a1aa1"},"installUnpackCode":""}
    [16:50:36.877] Starting forwarding server. localPort 1091 -> socksPort 1044 -> remotePort 39375
    [16:50:36.879] Forwarding server listening on 1091
    [16:50:36.880] Waiting for ssh tunnel to be ready
    [16:50:36.882] [Forwarding server 1091] Got connection 0
    [16:50:36.884] Tunneled 39375 to local port 1091
    [16:50:36.885] Resolved "ssh-remote+7b22686f73744e616d65223a225268696e6f4f53227d" to "127.0.0.1:1091"
    [16:50:36.897] ------




    [16:50:37.048] [Forwarding server 1091] Got connection 1
    [16:50:37.138] [Forwarding server 1091] Got connection 2
    [16:50:39.590] > * as described in the license ( https://go.microsoft.com/fwlink/?linkid=2077057)
    > *
    >
    > Checking server status on port 39375 with wget
    > 1bb5fa0390e8: start
    > SSH_AUTH_SOCK====
    > DISPLAY====
    > webUiAccessToken====
    > listeningOn==39375==
    > osReleaseId==ubuntu==
    > arch==x86_64==
    > tmpDir==/run/user/0==
    > platform==linux==
    > unpackResult====
    > didLocalDownload==0==
    > downloadTime====
    > installTime====
    > extInstallTime====
    > serverStartTime====
    > connectionToken==a11a1aa1-11aa-11a1-1111-1aa1a11a1aa1==
    > 1bb5fa0390e8: end
    >
    461da73c
        7
    461da73c  
       2022-05-03 16:55:32 +08:00
    @tracker647 "remote.SSH.useLocalServer": true
    试试?
    tracker647
        8
    tracker647  
    OP
       2022-05-03 17:03:53 +08:00
    @tracker647 日志里 false, 可我扩展里设置就是 true ,很鬼
    ![image-20220503170313089]( https://s2.loli.net/2022/05/03/XuHkBOhAwEGiN5F.png)
    tracker647
        9
    tracker647  
    OP
       2022-05-03 17:04:21 +08:00
    @461da73c 日志里 false, 可我扩展里设置就是 true ,很鬼
    ripperdev
        10
    ripperdev  
       2022-05-03 18:04:40 +08:00
    @tracker647 和 useLocalServer 无关,能看看你 Windows 上的~/.ssh/config 文件吗?
    ripperdev
        11
    ripperdev  
       2022-05-03 18:11:31 +08:00
    tracker647
        12
    tracker647  
    OP
       2022-05-03 18:17:35 +08:00
    ripperdev
        13
    ripperdev  
       2022-05-03 18:30:55 +08:00
    @tracker647 那就不太清楚了,我只改了 /etc/ssh/sshd_config 里的 PubkeyAuthentication 为 yes 就行了
    SvenKim
        14
    SvenKim  
       2022-05-03 20:56:42 +08:00 via Android
    之前有碰到过,应该是网络问题,导致 vscode 下载插件卡住了,需要手动下载后放到服务器的指定位置。
    https://blog.csdn.net/weixin_44633882/article/details/119589968
    adoal
        15
    adoal  
       2022-05-03 21:02:07 +08:00
    你先别急着集成 vscode ,命令行手工用 ssh 登录服务器看看
    DuckBurrito
        16
    DuckBurrito  
       2022-05-03 21:05:29 +08:00
    我上次也是这样子,好像是 authorized_keys 文件权限问题
    你试试看
    chmod 644 ~/.ssh/authorized_keys
    tracker647
        17
    tracker647  
    OP
       2022-05-03 21:06:11 +08:00
    @adoal 手工 ssh 能不带密码直接登录 但是 vscode 扩展就不行,不知道为啥
    adoal
        18
    adoal  
       2022-05-03 21:14:31 +08:00
    用 ssh-agent 来管理密钥试试?
    tracker647
        19
    tracker647  
    OP
       2022-05-03 21:31:05 +08:00
    @DuckBurrito 好像关联不大,虽然我这确实是卡 setting , 但是卡 setting 的原因是要求输入密码而不是单纯卡着,我最后输完密码后程序才去 root 找那个服务器文件:

    root@xxxxxxxxx's password:
    376d24784567: running
    Acquiring lock on /root/.vscode-server/bin/dfd34e8260c270da74b5c2d86d61aee4b6d56977/vscode-remote-lock.root.dfd34e8260c270da74b5c2d86d61aee4b6d56977
    Found existing installation at /root/.vscode-server/bin/dfd34e8260c270da74b5c2d86d61aee4b6d56977...
    Checking /root/.vscode-server/.dfd34e8260c270da74b5c2d86d61aee4b6d56977.log and /root/.vscode-server/.dfd34e8260c270da74b5c2d86d61aee4b6d56977.pid for a running server
    Looking for server with pid: 68202
    Found running server...
    DuckBurrito
        20
    DuckBurrito  
       2022-05-03 21:38:37 +08:00 via Android
    @tracker647 可以看看你服务器的日志
    tracker647
        21
    tracker647  
    OP
       2022-05-03 21:43:29 +08:00
    @SvenKim 才发现自己 A 错人了。。。
    lixile
        22
    lixile  
       2022-05-03 23:19:41 +08:00
    @tracker647 /root/.vscode-server/bin/dfd34e8260c270da74b5c2d86d61aee4b6d56977 这么目录下是否有文件被锁死了
    可以试试删除这个文件夹 这个对我比较常见
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   986 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 19:20 · PVG 03:20 · LAX 11:20 · JFK 14:20
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.