The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Hiding app window amessbee High Level Programming 1 12-05-2006 11:03 AM
Apache, hiding the url blesets UNIX for Dummies Questions & Answers 2 07-12-2005 02:08 PM
Hiding login/password in process! ctcuser UNIX for Dummies Questions & Answers 5 05-19-2004 10:39 AM
Hiding an IP address datopdog IP Networking 1 11-11-2002 07:18 PM
Hiding password from ps sudojo Shell Programming and Scripting 7 04-04-2002 05:52 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-24-2008
Cass3 Cass3 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 4
Hiding password for FTP in a script

Hi,

I have a simple script to ftp from unix to a mainframe to get and put files. Currently I have the password setup in a VARS file and dereference the var in my script. Doing it this way allws me to change the password in only one place but it is still viewable for many people. Is there any other way to hide the password for the ftp command?

Thank you!
  #2 (permalink)  
Old 10-24-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink There are 'hiding' steps you could take

These could be understood by anyone capable of reading the execution script - they would see the way you determine the true password.


Code:
> echo $var3
3jklomnepq
> pwd=$(echo $var3 | cut -c2,5,8)
> echo $pwd
joe

And there are ways to build upon something like this - to take that first digit and understand it as the offset. I sort of did that here with the first digit being 3 and then taking character 2, then character 5 (2+3), then character 8 (5+3). I just forced the math rather than adding a couple commands to have the cut know what positions to cut.
  #3 (permalink)  
Old 10-24-2008
Cass3 Cass3 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 4
Hi Joey,

Thanks for the reply. In your example people will still be able to go to the VARS file and see the password. Are there any FTP specific param files that the password could be put it that would make it harder to find? In my internet search I saw some code use $PASSWORD$ but it was not explained.

Thanks again!
  #4 (permalink)  
Old 10-24-2008
sethcoop sethcoop is offline
Registered User
  
 

Join Date: Oct 2008
Location: United States
Posts: 34
Is sftp an option? If you use sftp you can just exchange keys and never have to worry about the password being viewable...
  #5 (permalink)  
Old 10-24-2008
Cass3 Cass3 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 4
Hi sethcoop,

I do believe that sftp is available. How would I assign the keys?

Thank you
  #6 (permalink)  
Old 10-24-2008
sethcoop sethcoop is offline
Registered User
  
 

Join Date: Oct 2008
Location: United States
Posts: 34
Generate your keys with the command "ssh-keygen".. take all default values... you will see the following and it will create two files for you... the public and private keys...


Code:
sethcoop@burn:~$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/sethcoop/.ssh/id_rsa):
Created directory '/home/sethcoop/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/sethcoop/.ssh/id_rsa.
Your public key has been saved in /home/sethcoop/.ssh/id_rsa.pub.
The key fingerprint is:
3c:58:48:6b:9e:9c:c3:72:1b:8f:a9:f8:a5:c4:31:29 sethcoop@burn
sethcoop@burn:~$ cd .ssh
sethcoop@burn:~/.ssh$ ls -al
total 16
drwx------ 2 sethcoop sethcoop 4096 2008-10-24 12:16 .
drwxr-xr-x 3 sethcoop sethcoop 4096 2008-10-24 12:15 ..
-rw------- 1 sethcoop sethcoop 1671 2008-10-24 12:16 id_rsa
-rw-r--r-- 1 sethcoop sethcoop  411 2008-10-24 12:16 id_rsa.pub
sethcoop@burn:~/.ssh$

now you can take the contents of the id_rsa.pub file and add it to the /home/userid/.ssh/authorized_keys file on the remote server.

Watch out for you permissions because they have to be correct.. ie (your home directory can only be user writable the .ssh direcotry should have 700 permissions and the authorized_keys file should have 600 permissions).

when you have the public key shared the you can type in

Code:
$ sftp userid@remotehost

and it will log you in...

hope this works... let us know if you have any troubles.
  #7 (permalink)  
Old 10-24-2008
Cass3 Cass3 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 4
I just found out that we do not have SFTP on the mainframe systems I need to go to.

Thanks for your help.
Closed Thread

Bookmarks

Tags
ssh automatic login

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:31 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0