Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is it possible to create a new user on Linux, in way that I will not use password that asked from scp ???

For example

    scp my_new_login@100.119.100.11:/home/dir/file . (scp not ask about password) 

The target is to copy /home/dir/file to current directory without password, by changing login and password configuration/setup

I create the login/password by this script:

 more user.sh 
 #!/bin/sh
 UNAME=my_new_login
 UPASS=MY_PASS
 wall "$UNAME $UPASS"
 useradd "$UNAME"
 echo "$UPASS" | passwd "$UNAME" --stdin
 usermod -g restricted "$UNAME"
share|improve this question

1 Answer 1

With SSH, you have two options to avoid typing a password when prompted:

  1. Key-based authentication
  2. Something like an expect script to type in the username/password when prompted automatically.

I highly recommend the first option over the second one.

share|improve this answer
    
sorry I cant use axpect , and I cant use key-based , I need other options , –  Diana Nov 14 '11 at 13:24
1  
If you want to use SCP, there aren't any other options. You could use other languages besides expect, but these two approaches are the only ones available. If you really can't use either, you'll need to use a less secure protocol for file transfer. –  JakePaulus Nov 14 '11 at 13:33
    
so if I want to use sftp in EOF loop is it posible? –  Diana Nov 14 '11 at 13:55
    
You can submit SFTP commands in HEREDOC format in a shell script, but SFTP (which is simply the next generation replacement for SCP) does not support inputting a password in batch mode. In this case, you cannot even use an expect script. –  JakePaulus Nov 14 '11 at 14:17

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.