Saving credentials for automatic use

I have already looked around, and since I am not a specialist in security or encryption, I still do not understand how to implement encryption in my program. I need a server to log into his gitHub account to update code files with special headers. The only hang I have now is to save / get server credentials.

PushOptions push = new PushOptions { Credentials = new UsernamePasswordCredentials { Password = "password", Username = "Username" } }; 

How do I encrypt these credentials for storage? I know that its a bad idea to store them in code, as in the example, and it would be a bad idea to also store them in any file that is not encrypted.

Also, the only user interaction I want happens when they compile and configure the program on the server. It's like a cronjob on a linux server, in case that matters. Another detail that I want to point out is I use libgit2sharp, but previously used a bash script and ssh for authentication for testing.

+6
source share
1 answer

The best solution I found is simply putting them in a log file, since the server will already be password protected, and I could make it so that only one user (and I assume root) can read them, but few people know that a server exists, and only one needs to know exactly where to find them, and have credentials for this.

Despite the lack of security, he reaches the goal and still has sufficient protection. If someone does not want to receive credentials, it is easy enough to reset them with a password so that they lose access to the gitHub account.

0
source

Source: https://habr.com/ru/post/972720/


All Articles