示例#1
0
        public SshHelper()
        {
            // Keys generation at every application start
            SshKeys keys = SshKeysManagement.GenerateKeys();

            this.PublicKey  = keys.PublicKey;
            this.PrivateKey = keys.PrivateKey;
        }
示例#2
0
        public static SshKeys GenerateKeys()
        {
            SshKeys keys = new SshKeys();

            var returnValue = ShellHelper.Bash($"ssh-keygen -t ecdsa -q -f \"{homePath}/.ssh/temp\" -N \"\"", operativeSystem);

            keys.PrivateKey = File.ReadAllText($"{homePath}/.ssh/temp");
            keys.PublicKey  = File.ReadAllText($"{homePath}/.ssh/temp.pub");

            // Deleting temporary files
            File.Delete($"{homePath}/.ssh/temp");
            File.Delete($"{homePath}/.ssh/temp.pub");

            return(keys);
        }