0

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"
Diana
  • 261
  • 3
  • 10
  • 19

1 Answers1

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.

JakePaulus
  • 2,347
  • 16
  • 17
  • 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