I have a PHP script which connects via SFTP to servers to get data from there. That's a necessary thing for my project.
But how to store the credentials to this servers in my MYSQL-database? I don't want to store a SSH-password as plaintext, but I nearly have to, because otherwise the script can't connect? Is this true or is there another, secure way?
Snippet of my script:
while($row = mysqli_fetch_assoc($servers)) {
$srvip = $row["ip"];
$srvuser = $row["user"];
$srvpassword = $row["password"];
$file = file_get_contents('ssh2.sftp://' . $srvuser . ':' . $srvpassword . '@' . $srvip . ':22/files/data.txt');
}
Why not use MySQLs encryption options then you can decrypt the password when you run your initial MySQL query?
https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html Don't know if its applicable to your application but thats the way i'd go with it?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.