How to use scp with the password ?
Hi,
I am using scp command to copy one file to remote machine as follows Quote:
my doubt is how to pass the password along with the command so i don't have to give password again. I searched and find out about the keyfile set up but I do not need that idea . I want to use the password. So,kindly tell is it possible to use password if yes then how and if not then is there any other way to copy a file/directory in one command itself with out prompting for password. kindly tell some suggestion ,it is needed for my work. Thanks |
passwords should always be entered manually. Your requirements fit *EXACTLY* with a preshared key. Why would you not want to do that?
|
Thanks for the reply,
I do not want the idea of key file because,in my project I may not always need to have that key file set in all the target machines adn also local machine for all the target file. simply i have the password and a shell script to copy a file to all the machines.but it asking password so how to do this . Thanks |
In that case I would recommend to use expect. but keep in mind that hardcoding a password in a script is a very bad habit security wise.
|
Quote:
#!/usr/bin/expect spawn scp localfile root@192.168.1.13:/root/ expect "*password:*" { send "mypassword\r" } This will automatically put password when password's prompt will be detected. Note in your case you have to connect your shell's script with this expect's script. |
Can I just add further support to acid_kewpie & TobiSGD's advice: hard-coding a password is a really bad idea.
|
Hi
Keeping the password on shell script is very idea try to use ssh keygen instead of password.But Any way you can use these sshpass -p 'password' scp user-name@scp-server-ip-address:path-of-the-file/file-name destination-location |
Great sshpass is more better than expect
|
Quote:
|
All times are GMT -5. The time now is 02:07 AM. |