Commit 1ae7d55f authored by ligaishun's avatar ligaishun

增加公钥获取和密钥预处理

parent 107a384d
......@@ -389,4 +389,22 @@ func SafeCloseNode() (bool,error) {
return false,errors.New(stderr.String())
}
return true,nil
}
func GetPubKey()string{
f,err:=os.Open("/root/.ssh/id_rsa.pub")
if err!=nil{
log.Println(err)
}
r,_:=ioutil.ReadAll(f)
return string(r)
}
func Preprocessing(){//判断密钥对是否存在,存在则删除
_, err := os.Stat("/root/.ssh")
if err == nil || os.IsExist(err){
err=os.RemoveAll("/root/.ssh")
fmt.Println(err)
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment