Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to setup a ssh server that way, that it will accept password authentication only when there is no key added. So when a new user is created he can copy his key by password-based authentication.

share|improve this question
1  
Any hacker will love your arrangement. – MariusMatutiae 4 hours ago
1  
@MariusMatutiae perhaps you should say a bit more to help out our new member. – uSlackr 3 hours ago
1  
@MariusMatutiae, it's really small not very used server. Mainly for small personal purposes. But, why it's so bad arrangement? – michal.hosna 1 hour ago
up vote 6 down vote accepted

It is not possible with pure openssh. But you might be able to make it working using PAM. Conceptually, you should be able to /etc/pam.d/sshd a line with

password required pam_exec.so /usr/bin/test -s ~/.ssh/authorized_keys

I didn't test it, but you should be able to make up missing bits, if some.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.