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@ . (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 
 wall "$UNAME $UPASS"
 useradd "$UNAME"
 echo "$UPASS" | passwd "$UNAME" --stdin
 usermod -g restricted "$UNAME"

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.

  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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