SFTP without passing the password

 
Thread Tools Search this Thread
Special Forums UNIX and Linux Applications SFTP without passing the password
# 1  
Old 09-14-2011
Error SFTP without passing the password

Hi All,

I am trying to do SFTP without passing the password.

I did it by generating the Key pair on both source and destination servers but the problem is My script is running with BATCHADM user whereas I am doing SFTP using another username (sftp user1@destinationServer) due to which it is prompting for password.
(whereas if I run my script using the same user as SFTP user, it won't ask for password.)

Thanks in Advance.

Regards,
Ranjeet
# 2  
Old 09-14-2011
You could set up sudo to let you do the sftp with user A as user B so that the correct keys will be used.
# 3  
Old 09-14-2011
Its giving me error

ksh: sudo: not found

If you have code can you please pass... I am using the below code for this:

Code:
$ ssh kaurr06@destinationServer  bash -c "echo mypass | sudo -c kaurr06"

Moderator's Comments:
Mod Comment Please use [code] and [/code] tags when posting code, data or logs etc. to preserve formatting and enhance readability, thanks. Check your PMs.

Last edited by zaxxon; 09-15-2011 at 06:30 AM.. Reason: code tags, see PM
# 4  
Old 09-14-2011
It's giving 'not found' because there's no command named 'kaurr06'. Presumably that's a username?

While "echo mypass" is running, any user on the system may be able to see that plaintext. This is why you can't feed passwords into sudo automatically, it's specifically designed to prevent that for security reasons. This also applies to ssh and su. Better to get your keys working...

If batchadm can't get to your keys, creating a copy of the keys in a place batchadm has permissions to read could work.

Or better yet, give batchadm its own key.

Keys don't have to be in ~/.ssh/, you can specify an alternate location with -i. The folder they reside in must belong to the user in question and have 0700 permissions.

Code:
ssh -i /path/to/id_dsa username@host

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing -f with rm command in sftp

Is there any way I can pass -f with rm command in sftp? If I use it it treats -f as a file name to be removed. sftp> rm -f abcd Couldn't stat remote file: No such file or directory Removing /home/sdesai/-f Couldn't delete file: No such file or directory sftp> "rm -f" abcd Invalid... (2 Replies)
Discussion started by: Soham
2 Replies

2. Shell Programming and Scripting

SFTP prompting for password even though password is in script

Hi All, I am trying to transfer a file from one server to a remote server using SFTP. Client is not ready for key setup. I am working on Solaris 10. Here is the code. #!/bin/ksh # sample automatic Sftp script to dump a file USER="user1" PASSWORD="pass1" HOST="host1" sftp $USER@$HOST... (6 Replies)
Discussion started by: megha2525
6 Replies

3. UNIX and Linux Applications

SFTP Passing without DSA Key check

Hi, I am trying to connect through SFTP. Though the DSA 2048 public key is installed in the server machine, the connection is established only with password authentication! When i turn off password authentication in sshd_config file the connection is not working. Please advise, Best... (0 Replies)
Discussion started by: Maharajan
0 Replies

4. UNIX for Dummies Questions & Answers

SFTP Passing without DSA Key check

Hi, I am trying to connect through SFTP. Though the DSA 2048 public key is installed in the server machine, the connection is established only with password authentication! When i turn off password authentication in sshd_config file the connection is not working. Please advise, Best... (0 Replies)
Discussion started by: Maharajan
0 Replies

5. Solaris

SFTP passing variables date

Hi, Anyone can help me on how to solve my problem not getting the actual $DATE saying . Here my scripts; #!/bin/sh DATE='20110331' sftp -oUserKnownHostsFile=/.ssh/known_hosts -oIdentityFile=/.ssh/id_rsa -b /source/transfer.sh server1@sftp.com <<EOF #tranfer.sh put... (3 Replies)
Discussion started by: fspalero
3 Replies

6. Shell Programming and Scripting

passing password to a command

Hi all, I have the expect binaries in our boxes.. I want to pass a passwd to a command automatically without manual intervention using "/<path_of_expect>/expect/<version>/bin/autopasswd" The below command will ask passwd in my script cleartool rmtag -all <vob_tag> #Some... (4 Replies)
Discussion started by: raghu.iv85
4 Replies

7. UNIX for Dummies Questions & Answers

ISSUE on SFTP fucntion ,parameter passing!

Hi Everyone!! Hey i created a SFTP function to FTP the file from unix to Linux. I need to FTP the 48 files from unix to linux. IP=$1 Userid=$2 Prikeypath=$3 SrcPath=$4 DstPath=$5 Files=$6 BATCHFILE=sftp.batch.$$ LOGFILE=sftp.log.$$ #Compose batch file & pass as argument to the... (1 Reply)
Discussion started by: bobprabhu
1 Replies

8. Shell Programming and Scripting

Passing variables: sftp using -b batchfile

Hi All, I have created a script for an sftp transfer that works without a date variable being passed, I want it to work with a date variable being passed. So, my initial script, mainsftp.sh, looks like this: ----------------------------------------------------------------------- #... (1 Reply)
Discussion started by: j_miller
1 Replies

9. UNIX for Advanced & Expert Users

Passing a password to su

Hi I am running unix commands through Oracle, but I want to be able to run sftp which oracle cannot use. What I want to do is run a script which runs as oracle user but has the su command in, to connect as another user that has sftp access. I am trying the below. su - dwintuser -c gary.ksh... (2 Replies)
Discussion started by: colesga
2 Replies

10. Shell Programming and Scripting

passing password to rlogin

I have access to seperate Unix server that has specific scripts that I need to run from time to time. What I would like to do is pass my password in the script, instead of having to type the password then run the script all from the original script. Is this possible? ;) (2 Replies)
Discussion started by: jagannatha
2 Replies
Login or Register to Ask a Question