Is it safe and secure to save username and password in a batch file and use it to connect to putty ? Batch file contains below command:
start putty -ssh -load session -l username -pw password
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
Storing plain text passwords is never safe, generally speaking.
Given that, it's your job to determine how sensible this data is and find a good compromise between security and comfort.
If a malicious user gains access to your machine, they can view the batch file just like a plain text file and get your username and password. Assuming that you are either putting the batch file in an easily accessible place (such as your desktop) or inside a directory in the PATH variable, it won't be hard to find if someone wants to.
If you write the batch script, it is best practice to still have it prompt you for your password.
You may be able to hide your password in an alternate data stream, as shown here. But I must caveat that by saying that it's still not secure. Batch scripting is simply a way for your shell to automatically run commands that you have pre-written. It can't be encrypted or obfuscated. Additionally, the script must be able to read the password in plain text in order to use it in your command.
If you are adamant about automating your workflow for things that require entering passwords, one of your better options may be to use a compiled language such as C.