Power Shell 生成ssh key

生成新的 SSH 公私钥对

以下PowerShell脚本检查是否存在已有的 SSH 公私钥对,如果不存在,则生成一对新的公私钥对

if ( (-not (Test-Path -Path $HOME/.ssh -PathType Container)) -or `
      (-not (Test-Path -Path $HOME/.ssh/id_rsa.pub -PathType Leaf)) -or `
      (-not (Test-Path -Path $HOME/.ssh/id_rsa -PathType Leaf)) ) {
  ssh-keygen
}

查看公钥

cat $HOME/.ssh/id_rsa.pub
posted @ 2022-08-30 17:26  东百牧码人  阅读(513)  评论(0)    收藏  举报