39 Star 222 Fork 51

chuanjiao10 / kasini3000

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gx更新主控机ssh秘钥1.ps1 1.96 KB
一键复制 编辑 原始数据 按行查看 历史
chuanjiao10 提交于 2022-07-11 15:29 . 更新:psreadline库
#建议保存编码为:bom头 + utf8
#判断有秘钥1后,移动到秘钥3。重生成秘钥1。
if ( ($IsWindows -eq $True) -or ($PSVersionTable.psversion.major -lt 6) ) #win
{
& 'c:\ProgramData\kasini3000\0k_source.ps1'
}
if ($IsLinux -eq $True)
{
& '/etc/kasini3000/0k_source.ps1'
}
if ( ($IsWindows -eq $True) -or ($PSVersionTable.psversion.major -lt 6) ) #win
{
if (Test-Path -LiteralPath "$env:USERPROFILE\.ssh\id_rsa")
{
if (Test-Path -LiteralPath "${global:kasini3000_data_path}\ssh_key_files_old2")
{
Remove-Item -Path "${global:kasini3000_data_path}\ssh_key_files_old2\*"
}
else
{
Write-Warning "警告,找不到旧2密钥路径,将建立它"
mkdir -Name "${global:kasini3000_data_path}\ssh_key_files_old2"
}
Move-Item -Force -LiteralPath "$env:USERPROFILE\.ssh\id_rsa" -Destination "${global:kasini3000_data_path}\ssh_key_files_old2"
Move-Item -Force -LiteralPath "$env:USERPROFILE\.ssh\id_rsa.pub" -Destination "${global:kasini3000_data_path}\ssh_key_files_old2"
& 'chmod700win.ps1' "${global:kasini3000_data_path}\ssh_key_files_old1\id_rsa"
& 'jl建立主控机ssh秘钥1z.ps1'
}
else
{
& 'jl建立主控机ssh秘钥1z.ps1'
}
}
if ($IsLinux -eq $True)
{
if (Test-Path -LiteralPath '/root/.ssh/id_rsa')
{
if (Test-Path -LiteralPath '/root/kasini3000/ssh_key_files_old2/')
{
Remove-Item -Path '/root/kasini3000/ssh_key_files_old2/*'
}
else
{
Write-Warning "警告,找不到旧2密钥路径,将建立它"
mkdir -Name '/root/kasini3000/ssh_key_files_old2/'
}
Move-Item -Force -LiteralPath '/root/.ssh/id_rsa' -Destination '/root/kasini3000/ssh_key_files_old2/'
Move-Item -Force -LiteralPath '/root/.ssh/id_rsa.pub' -Destination '/root/kasini3000/ssh_key_files_old2/'
& 'jl建立主控机ssh秘钥1z.ps1'
}
else
{
& 'jl建立主控机ssh秘钥1z.ps1'
}
chmod 600 /root/.ssh/id_rsa
chmod 600 /root/kasini3000/ssh_key_files_old1/id_rsa
chmod 600 /root/kasini3000/ssh_key_files_old2/id_rsa
}
exit 0
PowerShell
1
https://gitee.com/chuanjiao10/kasini3000.git
git@gitee.com:chuanjiao10/kasini3000.git
chuanjiao10
kasini3000
kasini3000
master

搜索帮助