LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 05-26-2009, 04:38 AM   #1
MCD555
Member
 
Registered: May 2009
Location: Milan, Italy
Distribution: Ubuntu, Debian, Fedora, Oracle Linux
Posts: 109

Rep: Reputation: 10
SSH access method: public-key + password together....


Hi all,

I have to access to a SSH server where is request (together) a key authentication and a password authentication.
This is not a particular problem but I would like to schedule a scp to that server with a simple script but and don't know how or if it is possible to pass the password.....
I tried something like:

Code:
echo Password | scp -v  [local_file] user@sshsrv:[dest_file]
but, obviously, it doesn't works!
Any ideas?

Thank you all for your help!
 
Old 05-26-2009, 06:01 AM   #2
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 66
I did not try, but “expect” should be the tool you need. For example, here is the code of the “autopasswd” tool provided with expect (at least in Mandriva):
Code:
#!/bin/sh
# \
exec expect -f "$0" ${1+"$@"}
# wrapper to make passwd(1) be non-interactive
# username is passed as 1st arg, passwd as 2nd

set password [lindex $argv 1]
spawn passwd [lindex $argv 0]
expect "assword:"
send -- "$password\r"
expect "assword:"
send -- "$password\r"
expect eof
Yves.
 
Old 05-26-2009, 08:49 AM   #3
MCD555
Member
 
Registered: May 2009
Location: Milan, Italy
Distribution: Ubuntu, Debian, Fedora, Oracle Linux
Posts: 109

Original Poster
Rep: Reputation: 10
Thank you very much Yves,

but may I couldn't be able to install expect.....or better, I'd like to know if this issue could be solved with a simple script (but implicity the response to this question is "NO") .....

Anyway, I'm trying to install expect on my AIX-like system.

Thanks again,
Mauro


Quote:
Originally Posted by theYinYeti View Post
I did not try, but “expect” should be the tool you need. For example, here is the code of the “autopasswd” tool provided with expect (at least in Mandriva):
Code:
#!/bin/sh
# \
exec expect -f "$0" ${1+"$@"}
# wrapper to make passwd(1) be non-interactive
# username is passed as 1st arg, passwd as 2nd

set password [lindex $argv 1]
spawn passwd [lindex $argv 0]
expect "assword:"
send -- "$password\r"
expect "assword:"
send -- "$password\r"
expect eof
Yves.
 
Old 05-26-2009, 09:57 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Is the password you are talking about possibly the passphrase for unlocking your private key? It seems odd that both pubkey authentication & login authentication would be used. Could be a misconfiguration of sshd_config, or PAM (if pam is used).

If it is the passphrase (on the client), then you can use ssh-agent & ssh-add to enter it when you start a session. The pass phrase protects the client's private key and isn't being prompted for by the server.

example:
eval $(ssh-agent)
ssh-add

Look for your .xsession file. You may be able to use ssh-agent when you log into X using your display manager by uncommenting the line
"# usessh yes" or changing "no" to "yes" if that is the case.

Then you can log into any server that has a copy of your public key without being prompted for a passphrase.

Last edited by jschiwal; 05-26-2009 at 10:01 AM.
 
Old 05-27-2009, 02:46 AM   #5
MCD555
Member
 
Registered: May 2009
Location: Milan, Italy
Distribution: Ubuntu, Debian, Fedora, Oracle Linux
Posts: 109

Original Poster
Rep: Reputation: 10
Thanks jschiwal,

but the password is not the one protecting my private key....
The server explicity request the use of a public key authentication and a user password to access (I know this could have no sense but that is!?!? ).

Thanks again!

Quote:
Originally Posted by jschiwal View Post
Is the password you are talking about possibly the passphrase for unlocking your private key? It seems odd that both pubkey authentication & login authentication would be used. Could be a misconfiguration of sshd_config, or PAM (if pam is used).

If it is the passphrase (on the client), then you can use ssh-agent & ssh-add to enter it when you start a session. The pass phrase protects the client's private key and isn't being prompted for by the server.

example:
eval $(ssh-agent)
ssh-add

Look for your .xsession file. You may be able to use ssh-agent when you log into X using your display manager by uncommenting the line
"# usessh yes" or changing "no" to "yes" if that is the case.

Then you can log into any server that has a copy of your public key without being prompted for a passphrase.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
open-ssh vs. commercial ssh (tru64), public-key auth not possible? cf050 Linux - Networking 8 03-28-2012 11:15 AM
password policy with public key? pete83 AIX 7 02-04-2009 08:05 AM
Private/Public key vs. Password authentication w/ SSH MykeV Linux - Security 5 11-25-2007 11:49 AM
ssh to remote machine with public-key method 2007fld Linux - Security 2 08-13-2007 03:13 PM
ssh using public key jkmartha Linux - Networking 1 05-04-2005 02:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 01:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration