Visit Our UNIX and Linux User Community

supply password to scp with out interacting

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting supply password to scp with out interacting
# 1  
Old 09-09-2009
supply password to scp with out interacting


I am trying to supply password to scp with out having manual interaction. Like, store the password in a variable and it should be supplied to the scp when it prompted for the password. Is there any other way than the user authentication and using "expect" in perl script. i.e is this possible with stty and stdin or stdout commands.

Thanks & Regards,

Last edited by pc_raghu; 09-09-2009 at 09:04 AM..
# 2  
Old 09-09-2009
You can actually try Password less authentication...

1)install ssh and make sure it is running. you can use putty or telnet to test
telnet to port 22 on remote system

2)generate a key on local system ( as user required )
ssh-keygen -t rsa
ssh-keygen -t dsa

Follow the on-screen instructions, but don't set a password when prompted, as you will then need to enter the password each time you want to use the key. This creates a private and a public key file.

cd to .ssh on the home directory of the user.

3)Now you just copy the contents of the public key file in .ssh/ or .ssh/, and append it to the .ssh/authorized_keys file on the remote host and user you want to use when logging in. You need to append the public key file contents to each machine you want to log in to automatically.

Then you can try scp'ing like the following..
scp -pqB -i /<user>/.ssh/id_dsa_noauth ${HOST}:<source>  <local directory>

Last edited by Tuxidow; 09-09-2009 at 09:02 AM..
# 3  
Old 09-09-2009

I am also curious to know: is there any other way to supply a password to scp apart from ssh equivalence? Smilie


# 4  
Old 09-09-2009
I am also curious to know: is there any other way to supply a password to scp apart from ssh equivalence?
Yes. expect, shell, lftp among others. A simple seach on the Internet will return many examples.

Previous Thread | Next Thread
Test Your Knowledge in Computers #297
Difficulty: Easy
Linux Mint can be booted and run from a USB flash drive on any modern computer capable of booting from a USB drive.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

scp without password

Hello experts, OS : CentOS Could you please help me with the following scenario : I wish to use scp command in order to copy a file (say : f1.txt) from server 2 to server 1. Both servers have a common user (say : user1) configured. Also, the file is owned by the same user on both... (2 Replies)
Discussion started by: H squared
2 Replies

2. Shell Programming and Scripting

SFTP / SCP using password

Hi, I was provided with sftp servername, user and password and the requirement is to connect to sftp server using credentials provided and drop the file. Manually i am able to connect with commands like sftp user@servername and after clicking enter, i was asked for a password and entering... (4 Replies)
Discussion started by: forums123456
4 Replies

3. Linux

Regarding scp with out password

Dear all, I have two servers A and B. I want to do scp with out password between these two servers. I created ssh-keygen and copied the file to each of them in authorized_keys. But I could login only from B to A with out password. From A to B it is asking for a password. ... (5 Replies)
Discussion started by: jegaraman
5 Replies

4. UNIX for Advanced & Expert Users

scp without prompting for password

I am trying to copy a file from remote machine using scp. I followed the steps to configure public/private key usage. But still prompting for password when I do ssh. I did the following steps to configure scp without asking password Step 1 : local host > ssh-keygen -t rsa and when prompted... (9 Replies)
Discussion started by: satish@123
9 Replies

5. Red Hat

sftp/scp without password

Hi, I want to use sftp/scp without password.How can I do that ?? I plan to use script with scp/sftp and execute by cronjob ,any sample or example?? How can I test the scp/sftp working or not in the same user account , in the same red linux server?? any suggestion ??? (5 Replies)
Discussion started by: chuikingman
5 Replies

6. UNIX for Dummies Questions & Answers

scp without password - NT to UNIX

Hi guys, I wasn't sure which thread to include this one in (unix or shell scripting) but chose here based on search results. I need to automate a process which requires the need to transfer a file from a machine running on NT to the database server on UNIX. I've found this and a number of other... (7 Replies)
Discussion started by: Dird
7 Replies

7. UNIX for Advanced & Expert Users

How to supply the password in a ping command ?

for i in $var; do for j in $var; do if then ssh -x -a "$host_login_name"@${i} ping -c 3 -s 3 ${j} if then printf "Success\n" else printf "Failed\n" fi fi done done Enter your box login... (2 Replies)
Discussion started by: happyrain
2 Replies

8. UNIX for Advanced & Expert Users

scp without password

Hi, when I use scp test.jsp user@remote:/tmp/ I'm prompted user@remote's password: How can I avoid it ? Thank you. (8 Replies)
Discussion started by: big123456
8 Replies

9. Shell Programming and Scripting

scp scripting without asking password

I like to copy a file from one server server1 from path path1 to another server server2 to path path2. User logging in both the servers are same say user1 I tried to use ssh to generate public/private key pairs and then copy without prompting for password. These are the steps i followed ... (5 Replies)
Discussion started by: jwala
5 Replies

10. AIX

Supply Password Thru Script

Hello, I am using AIX 5 and one of the application does certain db updation daily and runs few script. One script among them calls another program, which in turn asks for a user Id and password. Is there anyway to use 'expect' of something similar on AIX so that while calling that program of... (1 Reply)
Discussion started by: panchpan
1 Replies

Featured Tech Videos