Visit Our UNIX and Linux User Community


How to enforce interactive keytool?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to enforce interactive keytool?
# 1  
Old 03-28-2017
Hammer & Screwdriver How to enforce interactive keytool?

i am reading line by line from a file as below

Code:
while IFS= read -r var
do
...
...
...
done < "hello.txt"

I added the keytool command in the do while loop as below.

Code:
while IFS= read -r var
do
...
keytool -genkey -alias $fname -keyalg RSA -keystore $fname.jks -keysize 2048
...
done < "hello.txt"

But instead asking user to input the details the keytool is reading input from hello.txt and fails with the below error.

Quote:
Enter keystore password: Re-enter new password: They don't match. Try again
Enter keystore password: Keystore password is too short - must be at least 6 characters
Enter keystore password: Keystore password is too short - must be at least 6 characters
Too many failures - try later
Can you help me fix this problem ?
# 2  
Old 03-28-2017
Code:
while read LINE
do
        something-that-needs-terminal < /dev/tty
done < inputfile

I'm a little surprised keytool doesn't do this automatically, though. Usually things that read passwords absolutely insist on using the terminal. But if it's a bulk generation tool it makes sense.
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 03-28-2017
Well, yes, you redirect stdin from "hello.txt", and keytool reads from stdin (c.f. man keytool)... Try opening "hello.txt" on another file descriptor.
# 4  
Old 03-28-2017
Quote:
Originally Posted by Corona688
Code:
while read LINE
do
        something-that-needs-terminal < /dev/tty
done < inputfile

I'm a little surprised keytool doesn't do this automatically, though. Usually things that read passwords absolutely insist on using the terminal. But if it's a bulk generation tool it makes sense.
Thank you @Corona .... Resolved.
This User Gave Thanks to mohtashims For This Post:

Previous Thread | Next Thread
Test Your Knowledge in Computers #329
Difficulty: Easy
The NVidia named the GTX 1080 because it can only render at a 1920x1080 screen resolution.
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to enforce user to Enter text when login to a UNIX / Linux system?

Hi. I inject my tracklogin.sh script in the profile of each user. $ more .profile ./tracklogin.sh # This is the default standard profile provided to a user. MAIL=/usr/mail/${LOGNAME:?} bash-3.2$ more tracklogin.sh #!/bin/bash tdate=$(date +"%d%m%y") mkdir -p /tmp/root_log... (20 Replies)
Discussion started by: mohtashims
20 Replies

2. Programming

Question regarding keytool

I first generated jks using keytool -genkey -alias keyAlias-keyalg RSA -keypass changeit -storepass changeit keystore keystore.jksThen i generated the csr using keytool -certreq -alias $addr -sigalg SHA256withRSA -keystore $addr.jks -file $addr.csr Below is how i self sign and generate the... (0 Replies)
Discussion started by: mohtashims
0 Replies

3. Shell Programming and Scripting

How-to enforce check on getopts command

here is my script that expects the user to run it like ./best.sh -f /tmp/log.txt more best.sh #!/bin/bash while getopts ":f:" opt; do case $opt in f) file_in="$OPTARG" ;; \?) echo "Invalid option -$OPTARG" >&2 ;; esac done uname -a SunOS mymac 5.11 11.2 sun4v... (15 Replies)
Discussion started by: mohtashims
15 Replies

4. Solaris

Keytool command to check expiration dates of certificates

Friends, I'm in search of a keytool command which pulls the expiration dates of certificates in keystore. I have around 200 certs in my keystore, so would like to know if we have any script/command which can pull expiration dates of certificates at one run. (3 Replies)
Discussion started by: fop4658
3 Replies

5. Homework & Coursework Questions

How to write script that behaves both in interactive and non interactive mode

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines. It then prompts for deletion of the file. If user supplies arguments with the script , then it works on those files... (8 Replies)
Discussion started by: rits
8 Replies

6. Homework & Coursework Questions

Help with Interactive / Non Interactive Shell script

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines. It then prompts for deletion of the file. If user supplies arguments with the script , then it works on those files... (1 Reply)
Discussion started by: rits
1 Replies

7. Solaris

How to enforce all users to change their password

Hi All, How to enforce all users to change their password when they try to login. I am having Solaris 9 and 10. Even it would be much better if anyone can say to enforce all users to change their password next morning they login. Thanks in advance, Deepak (3 Replies)
Discussion started by: naw_deepak
3 Replies

8. Solaris

How to enforce login as specific user in Solaris

Hi, I need to implement something that will enforce login to a Solaris server as a particular, specifed user. After this login stage, users will be able to "su -" to whichever user they wish, by which time their activity will be captured by some sort of script (yet to be written). What I need... (7 Replies)
Discussion started by: jamiegeo1
7 Replies

9. HP-UX

How to enforce users not to modify their command history.

As a system administrator. sometimes we see the users are trying some commands dangerous for the system health and remove them from their individual coomand history file. How it is possible to enforce that the normal usres will will not be able to modify the history. Thanks in advance. Partha (4 Replies)
Discussion started by: partha_bhunia
4 Replies

Featured Tech Videos