@@ -235,6 +235,15 @@ public string SSHGen()
235235
236236 return System . IO . File . ReadAllText ( Path . Combine ( Environment . GetEnvironmentVariable ( "HOME" ) , ".ssh" , "id_rsa.pub" ) ) ;
237237 }
238+ /// <summary>
239+ /// Get curret open ssh key
240+ /// </summary>
241+ /// <returns></returns>
242+ [ HttpGet ( "SShGetCurrentKey" ) ]
243+ public string SSHGetCurrentKey ( )
244+ {
245+ return System . IO . File . ReadAllText ( Path . Combine ( Environment . GetEnvironmentVariable ( "HOME" ) , ".ssh" , "id_rsa.pub" ) ) ;
246+ }
238247
239248 /// <summary>
240249 /// Load and copy id_rsa and id_rsa.pub from cfg directory to ./ssh/
@@ -252,8 +261,12 @@ public string LoadSSHKeys()
252261 System . IO . File . Copy ( Path . Combine ( AppContext . BaseDirectory , "cfg" , "id_rsa" ) , Path . Combine ( Environment . GetEnvironmentVariable ( "HOME" ) , ".ssh" , "id_rsa" ) , true ) ;
253262 System . IO . File . Copy ( Path . Combine ( AppContext . BaseDirectory , "cfg" , "id_rsa.pub" ) , Path . Combine ( Environment . GetEnvironmentVariable ( "HOME" ) , ".ssh" , "id_rsa.pub" ) , true ) ;
254263
255- System . IO . File . Delete ( Path . Combine ( AppContext . BaseDirectory , "cfg" , "id_rsa" ) ) ;
256- System . IO . File . Delete ( Path . Combine ( AppContext . BaseDirectory , "cfg" , "id_rsa.pub" ) ) ;
264+ var cmd = @"chmod 600 /root/.ssh/id_rsa" ;
265+ ShellHelper . Cmd ( cmd , folder , _logger ) ;
266+ cmd = @"chmod 600 /root/.ssh/id_rsa.pub" ;
267+ ShellHelper . Cmd ( cmd , folder , _logger ) ;
268+ //System.IO.File.Delete(Path.Combine(AppContext.BaseDirectory, "cfg", "id_rsa"));
269+ //System.IO.File.Delete(Path.Combine(AppContext.BaseDirectory, "cfg", "id_rsa.pub"));
257270 }
258271 catch ( Exception ex )
259272 {
0 commit comments