kerberos

背景

由于某些原因,需要使用kerberos登录服务器,但由于VScode没有原生支持,所以在这个地方写一下解决方法。

步骤

  1. 安装Kerberos等软件,按照要求进行配置
  2. 安装PuTTY
  3. 在PuTTY中设置一个名为remote的session,需要包括以下内容
    1
    2
    3
    Session->Host Name
    Connection->SSH->Auth->GSSAPI
    Connection->Data
  4. 编写C:/Users//ssh.bat脚本
    1
    2
    3
    echo OpenSSH
    SET mypath=%~dp0
    powershell %mypath%ssh.ps1
  5. 同目录下编写脚本ssh.ps1
    1
    2
    3
    4
    5
    6
    7
    8
    $ArgArray = [System.Collections.ArrayList]$Args
    $ind = $ArgArray.IndexOf("-F")
    if ($ind -ge 0) {
    $ArgArray.RemoveAt($ind)
    $ArgArray.RemoveAt($ind)
    }
    Write-Host $ArgArray
    & 'C:\Program Files\PuTTY\plink.exe' $ArgArray
  6. 修改vscode中的”remote.SSH.path”值,将其改为ssh.bat的路径
  7. 在ssh配置中添加以下内容
    1
    2
    3
    Host remote #上文中名为remote的配置
    HostName remote
    User XXXX