PDA

View Full Version : How to Hide Username/Passwords in shell scripts



secoonder
May 4th, 2014, 03:51 PM
Hello
i am using Ubuntu 12.04 Lts.
ı wrote script for backup.this script is executed by cron every night for file transfer
For ex:
User name:user
Pass :123
Remote ip :1.2.3.4
My script is : wget ftp://user:123@1.2.3.4/abcd.gbk.zip*
How to hide Username and password in script?
İs it impossible ?
Can you help me .Thank you.
Regards

ofnuts
May 5th, 2014, 03:02 PM
Not really because at some point user/pwd will be in the clear in the wget command anyway. Your best bet is to make the script readable only by those who can run it.

Using wget to retrieve file using the ftp protocol is a bit of overkill considering that there is a ftp client on all Linux machines. This FTP client can retrieve user/password from a user-specific .netrc file which may be a bit easier to control access to.

Habitual
May 7th, 2014, 03:26 PM
sftp protocol with ssh-key?

secoonder
December 25th, 2014, 07:32 AM
Habitual Thanks.
i tried sftp user@1.2.3.4 command , and solved it
Thanks a lot

Habitual
January 13th, 2015, 05:02 PM
You are very welcome.