LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-23-2005, 07:48 AM   #1
apt
Member
 
Registered: Dec 2004
Posts: 34

Rep: Reputation: 15
Shell Script Help


I have a simple shell script which is scheduled to download files from remote server(Simple FTP using Shell Script). In shell script i had hotcoded USERNAME and PASSWORD to string variables to access remote server.
Code:
		
                HOST='hostname'
		USER='username'
		AUTH='password'
how to prevent the USERNAME and PASSWORD not being seen by others when they just open up the shell script file?
 
Old 08-23-2005, 08:02 AM   #2
nelz
Member
 
Registered: Aug 2004
Posts: 34

Rep: Reputation: 6
Do you have SSH access to the remote server? If so, you could use scp with key authentication, so there are no passwords to exchange.
 
Old 08-23-2005, 08:03 AM   #3
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Hi.

There's not really a way around this. If you encrypt the password and username, you'll need another password to decrypt them, and that would have to be stored somewhere too (unless you can type it in each time the script runs).

You could create a new user just for this script, and limit read access to that user, so no-one else can open the script in the first place.

You might be better using SSH, and doing puplic/private key authentication (which can be done with no password), so there are no passwords to steal. The following should be useful:
http://www.linuxquestions.org/questions/answers/79

Dave
 
Old 08-23-2005, 08:11 AM   #4
apt
Member
 
Registered: Dec 2004
Posts: 34

Original Poster
Rep: Reputation: 15
Hi,
Thanks for the response. But i dont have SSH access to the remote server. Thatz why I used FTP to download files. Is that i can do this using Perl or bash scripts?

Last edited by apt; 08-23-2005 at 09:38 AM.
 
Old 08-23-2005, 08:12 AM   #5
dub.wav
Member
 
Registered: Aug 2003
Location: Norway
Distribution: FC4
Posts: 83

Rep: Reputation: 20
How about:
a) Ask for password each time
b) Save the password in a chmod 600'ed file only you can read.
 
Old 08-23-2005, 09:13 AM   #6
apt
Member
 
Registered: Dec 2004
Posts: 34

Original Poster
Rep: Reputation: 15
I am trying to automate(using crontab) this script without any manual intervention, in this way is there any solution.?

Last edited by apt; 08-23-2005 at 09:15 AM.
 
Old 08-23-2005, 09:27 AM   #7
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
You can use "~/.netrc" (man netrc).
 
Old 08-23-2005, 11:02 AM   #8
nelz
Member
 
Registered: Aug 2004
Posts: 34

Rep: Reputation: 6
Or ncftpget with the details stored in a file anywhere you like (but make sure you chmod 600 it).

Does anyone know why ncftpget and ncftpput do not use the ncftp bookmarks, as you can store the password encrypted in there?
 
Old 08-25-2005, 05:40 AM   #9
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
as jilliagre said

use ~/.netrc

it won't work if the file is readable.
needs to be chmod 600
 
Old 08-25-2005, 09:08 AM   #10
apt
Member
 
Registered: Dec 2004
Posts: 34

Original Poster
Rep: Reputation: 15
Thanks for your answers. I will try with these ones.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script inside shell script treotan Linux - General 4 02-19-2009 06:34 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-11-2005 11:08 PM
[SHELL SCRIPT] Write at the right of the shell window Creak Linux - General 2 04-02-2004 03:00 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration