Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Public Key Private key VS. password

Status
Not open for further replies.

neonep

Programmer
Jun 26, 2003
34
Hello all,

I wrote a script in Perl that uses sftp to put and get files from different servers. I have set up a public key/private key authentication on my box and so it never prompts for a password when I run the script for sftp'ing to another server. What I want to happen is, if someone else tries to run the script, if the public key/private key is not set, instead of sftp prompting for a password and hanging there, I just want it to throw an error and quit. How would I do that?
Your help will be greatly appreciated.
Thanks.
 
Show us some code, there's got to be a way to test the condition.

This public Key, Private key, that's not the server certificate ...?

I use an SFTP client, and had no idea you could this PGP setup
--Paul

cigless ...
 
You could probably use Expect, or Perl::SSH to setup a secure shell to the client first, and if that fails, so too will the SFTP, assuming the users are properly setup

--Paul

cigless ...
 
Here's a detailed explanation of my problem.

$rc = system("/usr/bin/sftp -b $command_file $userid\@$server >> $results_file 2>> $results_file");

the $command_file has the information on lcd and cd and stuff for the sftp.

if someone WITH a public key private key set up on his box and the server runs this script, it will easily copy the files without prompting for a password.

But if someone WITHOUT a public key private key set up on his box and the server wants to run my script, when it reaches the above line, it prompts for a password.

If that's the case, instead of prompting for the password, I want to print out an error saying something like "Public key private key authentication not set up"

I want to do this, because this script will be scheduled to run automatically and there will be noone to feed the password manually. The errors ( like the one I want ) will be logged in a log file though.

I hope this helps you understand my problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top