0

I'm writing a script that will connect to a remote FTP server and login using my username and password and then upload a file from my HDD to the server. I feel like there can be alternatives to hardcoding my sensitive information (password and username) in the code. Any suggestions? What's the best thing that can be done?

import ftplib
ftp = ftplib.FTP('ftp.mydomain.com')
ftp.login('username', 'password')
Debanik Dawn
  • 797
  • 5
  • 28
  • hi @debanik-dawn, you can use that -> https://stackoverflow.com/a/21215838/2572645 – Andy K Jul 19 '17 at 05:31
  • go through the discussion https://www.reddit.com/r/Python/comments/390z4z/is_it_possible_to_securely_store_actual_passwords/ – Equinox Jul 19 '17 at 05:36
  • @AndyK, that doesn't really help me in hiding my password. :/ – Debanik Dawn Jul 19 '17 at 06:34
  • Is using FTP a requirement? Or does the file just need to be sent to the FTP server? If the latter, this might help (https://stackoverflow.com/questions/68335/how-to-copy-a-file-to-a-remote-server-in-python-using-scp-or-ssh) otherwise you might want to check out the example from this question, as setting up a ssh key pair would be one way to avoid hard-coding credentials (https://stackoverflow.com/questions/25399635/how-to-connect-to-sftp-through-paramiko-with-ssh-key-pageant) – Andrew Zick Jul 20 '17 at 16:03
  • @DebanikDawn try this https://stackoverflow.com/a/4282261/2572645 – Andy K Jul 27 '17 at 16:48

0 Answers0