05-18-2016
Supply passphrase for ssh in script
I would like to write a bash shell script which will connect to remote server using passphrase. (I have public-private infrastructure created, and as per instruction, I must not use password less ssh).
This particular script will be fired from cron.
Can you please advice how I can supply the passphrase (from any file or any other way) in the script ?
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hello,
I want to use a shell-script to transfer data over sftp.
I donīt find a way to login in automatically.
I tried to send the password in a script like possible with
ftp
sftp user@server << cmd
password
cd /distant/directory
lcd /local/directoryget ssh_install
get ( or put) your... (2 Replies)
Discussion started by: olso
2 Replies
2. UNIX for Advanced & Expert Users
In which case could be better don't use a passphrase creating an authentication key for ssh comunications?
Thanks in advance. (1 Reply)
Discussion started by: Minguccio75
1 Replies
3. Solaris
Hello all,
Today we run ssh with keys on all our Solaris systems. But I wounder: Is it possible to add another authentication too. Like the os/system regular password so the users first need to enter the ssh phasssphrase and after that they need to enter the os/system password.
I need like... (3 Replies)
Discussion started by: jOOc
3 Replies
4. AIX
Hello,
I am using AIX 5 and one of the application does certain db updation daily and runs few script. One script among them calls another program, which in turn asks for a user Id and password. Is there anyway to use 'expect' of something similar on AIX so that while calling that program of... (1 Reply)
Discussion started by: panchpan
1 Replies
5. UNIX for Dummies Questions & Answers
can i use key with passphrase on a script/batch process?
i am not sure how to pass the pasphrase in the script. i'd like to automate
secure file transfer. thanks in advance (0 Replies)
Discussion started by: NoelSacay
0 Replies
6. Shell Programming and Scripting
Below is a part of my shell script. Currently I have shared the public key of the client with the host, therefore I will not be prompted for the password.
The key that has been created on the client is also without a passphrase. If it is created with a passphrase, the code I have will not... (3 Replies)
Discussion started by: farahzaiba
3 Replies
7. UNIX for Advanced & Expert Users
We have a number of linux clusters running Oracle. The clusters require that all member nodes have promptless/passwordless login through ssh (ie. the keys were created with null passphrases). We also have a management server that is not a member of any cluster but routinely connects to nodes of all... (3 Replies)
Discussion started by: Squeakygoose
3 Replies
8. OS X (Apple)
ssh passphrase permissions issues
I will try to be as thorough as possible, but keep in mind I am a designer, not a programmer... I do have linux mdadm experience and am reasonably comfortable behind the terminal, but I may need things to be spelled out for me. I am using 2 new-ish Macs with... (1 Reply)
Discussion started by: Ahab the Eskimo
1 Replies
9. Shell Programming and Scripting
Hi,
I have something like below code piece in ksh
while read machine
do
ssh $user@$machine < steps.ksh $RPI
done < $machine
here, after it gets logged in to server it is not considering the $PRI as argument for steps.ksh script
please suggest the fix. (1 Reply)
Discussion started by: rbalaj16
1 Replies
10. Solaris
Hi Folks,
I have setup a passwordless connection from my Linux ( source) machine toSolaris ( destination ) machine. I have added passphrase while creating the rsa key. Now problem is each time when i make a connection i have to give the passphrase to make connection. How to override this ?
I... (4 Replies)
Discussion started by: chidori
4 Replies
LEARN ABOUT PHP
ssh2_auth_pubkey_file
SSH2_AUTH_PUBKEY_FILE(3) 1 SSH2_AUTH_PUBKEY_FILE(3)
ssh2_auth_pubkey_file - Authenticate using a public key
SYNOPSIS
bool ssh2_auth_pubkey_file (resource $session, string $username, string $pubkeyfile, string $privkeyfile, [string $passphrase])
DESCRIPTION
Authenticate using a public key read from a file.
PARAMETERS
o $session
- An SSH connection link identifier, obtained from a call to ssh2_connect(3).
o $username
-
o $pubkeyfile
- The public key file needs to be in OpenSSH's format. It should look something like: ssh-rsa AAAAB3NzaC1yc2EAAA....NX6sqSnHA8=
rsa-key-20121110
o $privkeyfile
-
o $passphrase
- If $privkeyfile is encrypted (which it should be), the $passphrase must be provided.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1
Authentication using a public key
<?php
$connection = ssh2_connect('shell.example.com', 22, array('hostkey'=>'ssh-rsa'));
if (ssh2_auth_pubkey_file($connection, 'username',
'/home/username/.ssh/id_rsa.pub',
'/home/username/.ssh/id_rsa', 'secret')) {
echo "Public Key Authentication Successful
";
} else {
die('Public Key Authentication Failed');
}
?>
NOTES
Note
The underlying libssh library doesn't support partial auths very cleanly That is, if you need to supply both a public key and a
password it will appear as if this function has failed. In this particular case a failure from this call may just mean that auth
hasn't been completed yet. You would need to ignore this failure and continue on and call ssh2_auth_password(3) in order to complete
authentication.
PHP Documentation Group SSH2_AUTH_PUBKEY_FILE(3)