Sponsored Content
Operating Systems AIX Verifying a users password on AIX setup with LPA Post 302961355 by agent.kgb on Friday 27th of November 2015 05:47:44 AM
Old 11-27-2015
if only LPA was changed, authenticate() works quite well:

Code:
$ cat checkpw.c
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#include <limits.h>
#include <userpw.h>

int main(int argc, char *argv[])
{
        char *username, *pw, *msg = (char *)NULL;
        struct userpw *up;
        int rc, reenter;

        if (argc > 2) {
                fprintf(stderr, "Usage: %s [username]\n", argv[0]);
                return 2;
        }

        if (argc == 2) {
                /* username is in argv[1] */
                username = (char *)calloc(strlen(argv[1])+1, 1);
                if (!username) {
                        fprintf(stderr, "can't allocate memory for username\n");
                        return 3;
                }
                strncpy(username, argv[1], strlen(argv[1]));
        }

        if (argc == 1) {
                /* get current user */
                username = (char *)calloc(PW_NAMELEN + 1, 1);
                if (!username) {
                        fprintf(stderr, "can't allocate memory for username\n");
                        return 3;
                }
                rc = getlogin_r(username, PW_NAMELEN);
                if (rc) {
                        fprintf(stderr, "can't get current user's name, RC=%d\n", rc);
                        return 4;
                }
        }

        printf("Checking password for user %s\n", username);

        pw = getpass("Enter password: ");
        if (!pw) {
                fprintf(stderr, "can't obtain password for user %s\n", username);
                return 5;
        }

        do {
                rc = authenticate(username, pw, &reenter, &msg);
                if (msg) {
                        if (!reenter) {
                                fputs(msg, stderr);
                        }
                        free(msg);
                        msg = (char *)NULL;
                }
        } while (reenter);
        return rc;
}

Compilation:
Code:
$ cc checkpw.c -o checkpw

Check:
Code:
$ grep -p user /etc/security/passwd
user:
        password = {ssha512}06$verylongpassword
        lastupdate = 1448619478

$ ./checkpw user
Checking password for user user
Enter password:
$ echo $?
0

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

documentation for beginners setup virtual site, users, mailaccounts on raq 550

Greetings to all reading this, I am a Linux/Unix newbie webmaster with a dedicated server, a RaQ 550. I am looking for some step by step documentation about managing a server with shell (not the GUI), from adding a virtual site to adding users, email accounts etc. I can find only parts of this... (0 Replies)
Discussion started by: rolandk
0 Replies

2. Red Hat

SSH Prompts for Password After Keys Setup Successfully

I setup the keys between 2 servers, but my user account has no password specified for it (never set one up on the account for security reasons). When I try to SSH to the server, SSH prompts for a password that doesn't exist (so I can never connect successfully). Note: 'passwd -d Rynok' removes... (3 Replies)
Discussion started by: Rynok
3 Replies

3. Red Hat

setup sudo for cmd exec w/o password

i need to set up a user to execute a restricted command as another user and to be able to do so without entering a password. I understand the security concerns but let's not go there, unless you are really compelled to do so... The directive to permit is that I believe should work and did add to... (2 Replies)
Discussion started by: twk
2 Replies

4. Red Hat

how to setup An extra account with name 'unixuser' who can have the previlege to reset other users?

Hi I want to setup an extra account with name 'unixuser' who has the previlege to reset the passwords of other users like eng or myuser (other user). Please help me.. Waiting for a reply.. Thanks, MJavalkar (1 Reply)
Discussion started by: mjavalkar
1 Replies

5. Shell Programming and Scripting

How to setup a password less ftp??

hi, i want to setup a password less FTP to a remote server so that i can ftp to a remote server without the password. i have setup a passwordless ssh and i am able to use scp commands to connect to the remote server without asking for the password. but when i try to ftp to the same remote... (6 Replies)
Discussion started by: Little
6 Replies

6. Solaris

How can i setup ssh password-less login for particular user?

HI Community. I was trying to create ssh password less authentication for one user called night and it's not working for me. These are the steps I followed:- I have logged into the server and issued ssh-ketgen -t rsabash-3.2$ ssh-keygen -t rsa Generating public/private rsa key pair.... (4 Replies)
Discussion started by: bentech4u
4 Replies

7. UNIX for Advanced & Expert Users

Setup Samba Server to always ask user and password

How do I setup a Samba server to always ask to user and password, when a windows user, prints your files using a shared printer through a Samba Linux Server (CUPS)? (0 Replies)
Discussion started by: viga
0 Replies

8. AIX

Change password for many users on an AIX server

Hi I want to change password for around 100 users on an aix server. I have the list of those 100 users with me. instead of doing # passwd username for all the 100 users one by one, can you please help with a script through which we can change the password for all the 100 users in a... (2 Replies)
Discussion started by: newtoaixos
2 Replies

9. Red Hat

SSH password less setup asking for password

Hello Experts, when I am trying to connect my target server through sftp after creating ssh password less setup, it is asking for passowrd to connect. to setup this I followed below process: -->generated keys by executing the command "ssh-keygen -t rsa" -->this created my .ssh directory... (9 Replies)
Discussion started by: Devipriya Ch
9 Replies

10. UNIX for Beginners Questions & Answers

New to AIX: How do I setup high availability on an AIX System

I am new to AIX but not new to unix. I have an interview for an AIX systems admin position and I know they want someone who has knowledge of High Availability, Failover and LPARs From my research so far, It appear powerha is used to setup high availability and failover on Power systems but is... (2 Replies)
Discussion started by: mathisecure
2 Replies
LSH-PAM-CHECKPW(8)						    lsh manuals 						LSH-PAM-CHECKPW(8)

NAME
lsh-pam-checkpw - program to check a PAM username/password combination SYNOPSIS
lsh-pam-checkpw username-to-check DESCRIPTION
This manual page documents briefly the lsh-pam-checkpw command. This manual page was written for the Debian distribution because the orig- inal program does not have a manual page. Instead, it has documentation in the GNU Info format; see below. lsh-pam-checkpw is a program that checks if a username and password combination is valid for login by doing a PAM lookup. It is designed to be used as a password helper program for lshd (8), (eg. --password-helper=/usr/sbin/lsh-pam-checkpw. lsh-pam-checkpw takes one required argument, which is the username, and reads the password from stdin, then returns 0 if the password is valid, or 1 otherwise. Note that the password must be supplied exactly, ie. there must be no newline after the password, so if invoking from a shell, just type "<your-password><CTRL-D>". SEE ALSO
lsh(1), lshd(8). The programs are documented fully by Lsh, available via the Info system. AUTHOR
This manual page was written by Timshel Knoll <timshel@debian.org>, for the Debian GNU/Linux system (but may be used by others). lsh-pam-checkpw Jul 05 2002 LSH-PAM-CHECKPW(8)
All times are GMT -4. The time now is 01:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy