Skip to main content
added 254 characters in body
Source Link
Yaron
  • 4.4k
  • 2
  • 22
  • 33

There are several options:

  1. using sshpassusing sshpass

Execute the command:

sshpass -p 'password' scp filename user@host:
  • Install sshpass:

  • Ubuntu:

    sudo apt install sshpasssudo apt install sshpass

sshpass man

sshpass - noninteractive ssh password provider

sshpass is a utility designed for running ssh using the mode referred to as "keyboard-interactive" password authentication, but in non-interactive mode.

ssh uses direct TTY access to make sure that the password is indeed issued by an interactive keyboard user. Sshpass runs ssh in a dedicated tty, fooling it into thinking it is getting the password from an interactive user.

The command to run is specified after sshpass' own options. Typically it will be "ssh" with arguments, but it can just as well be any other command. The password prompt used by ssh is, however, currently hardcoded into sshpass.

  1. using expect (or other script)

  2. Using ssh with key-pair (instead of using password)

    Using expect (or other script)

write a script which will inject the password once it will identify the ssh password prompt

  1. Using ssh with key-pair (instead of using password)

IMHO - This is the most secure way, and it doesn't require using passwords.

Using public/private key in order to perform ssh or scp operation without having to enter a password.

  • More info can be found in this answer

  • Detailed information can be found here

There are several options:

  1. using sshpass

Execute the command:

sshpass -p 'password' scp filename user@host:
  • Install sshpass:

  • Ubuntu:

    sudo apt install sshpass

sshpass man

sshpass - noninteractive ssh password provider

sshpass is a utility designed for running ssh using the mode referred to as "keyboard-interactive" password authentication, but in non-interactive mode.

ssh uses direct TTY access to make sure that the password is indeed issued by an interactive keyboard user. Sshpass runs ssh in a dedicated tty, fooling it into thinking it is getting the password from an interactive user.

The command to run is specified after sshpass' own options. Typically it will be "ssh" with arguments, but it can just as well be any other command. The password prompt used by ssh is, however, currently hardcoded into sshpass.

  1. using expect (or other script)

  2. Using ssh with key-pair (instead of using password)

There are several options:

  1. using sshpass

Execute the command:

sshpass -p 'password' scp filename user@host:
  • Install sshpass:

  • Ubuntu:

    sudo apt install sshpass

sshpass man

sshpass - noninteractive ssh password provider

sshpass is a utility designed for running ssh using the mode referred to as "keyboard-interactive" password authentication, but in non-interactive mode.

ssh uses direct TTY access to make sure that the password is indeed issued by an interactive keyboard user. Sshpass runs ssh in a dedicated tty, fooling it into thinking it is getting the password from an interactive user.

The command to run is specified after sshpass' own options. Typically it will be "ssh" with arguments, but it can just as well be any other command. The password prompt used by ssh is, however, currently hardcoded into sshpass.

  1. Using expect (or other script)

write a script which will inject the password once it will identify the ssh password prompt

  1. Using ssh with key-pair (instead of using password)

IMHO - This is the most secure way, and it doesn't require using passwords.

Using public/private key in order to perform ssh or scp operation without having to enter a password.

  • More info can be found in this answer

  • Detailed information can be found here

Source Link
Yaron
  • 4.4k
  • 2
  • 22
  • 33

There are several options:

  1. using sshpass

Execute the command:

sshpass -p 'password' scp filename user@host:
  • Install sshpass:

  • Ubuntu:

    sudo apt install sshpass

sshpass man

sshpass - noninteractive ssh password provider

sshpass is a utility designed for running ssh using the mode referred to as "keyboard-interactive" password authentication, but in non-interactive mode.

ssh uses direct TTY access to make sure that the password is indeed issued by an interactive keyboard user. Sshpass runs ssh in a dedicated tty, fooling it into thinking it is getting the password from an interactive user.

The command to run is specified after sshpass' own options. Typically it will be "ssh" with arguments, but it can just as well be any other command. The password prompt used by ssh is, however, currently hardcoded into sshpass.

  1. using expect (or other script)

  2. Using ssh with key-pair (instead of using password)