Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Search Forums:



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-11-2010
Registered User
 

Join Date: Jul 2005
Location: Chennai
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Question Non-Interactive SFTP

Hi,

I need to sftp from one Unix Server (source) to another (destination) (both SunOS) non-interactively.

I did the following :

1) Generated public key in source server in $HOME/.ssh dir without giving any passphrase
2) Added the contents of the public key generated to authorized_keys2 file in destination server's $HOME/.ssh directory
3) Permissions for the .ssh dir's is 0700 and the key files is 0600
4) Created a file named "confg" in source $HOME/.ssh dir which has the below contents.


Host *
BatchMode yes
PasswordAuthentication no

Still its asking me for a password (not passphrase) when I give sftp destinationuserid@destinationservername in client

When I give the password, its getting connected. But I want non-interactive login where the sftp command should not be prompting me for any password ?

Please help me what I need to do here or if I am doing anything wrong here ?

Thanks,
Sabari Nath S

Last edited by Sabari Nath S; 03-11-2010 at 04:46 PM..
Sponsored Links
    #2  
Old 03-11-2010
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 8,506
Thanks: 67
Thanked 401 Times in 390 Posts
The home directory of the remote account has to be 755. For starters. And the key file gets named authorized_keys. If there are more than one key file just use

Code:
cat keyfile1 keyfile2 ... keyfilen > authorized_keys

If that doesn't help post the output of
Code:
ssh -vvv  remotebox

Sponsored Links
    #3  
Old 03-11-2010
fpmurphy's Avatar
who?
 

Join Date: Dec 2003
Location: /dev/ph
Posts: 4,043
Thanks: 35
Thanked 282 Times in 263 Posts
Also the permissions on the .ssh subdirectory should be set to 700 and the permissions of every file in the .ssh subdirectory should be 600.
    #4  
Old 03-12-2010
Registered User
 

Join Date: Jul 2005
Location: Chennai
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Hi,

I had already changed the permissions for all files under .ssh to 600 and the .ssh dir to 700

Client:



Code:
$ ls -ld .ssh
drwx------   2 cdbcdi   other        512 Mar 12 00:04 .ssh

$ cd .ssh

$ ls -l
-rw-------   1 cdbcdi   other         47 Mar 11 14:42 config
-rw-------   1 cdbcdi   other        883 Mar 11 12:48 id_rsa
-rw-------   1 cdbcdi   other        332 Mar 11 12:49 id_rsa.pub

$ cat config
Host *
BatchMode yes
PasswordAuthentication no

Server (Host):


Code:
$ ls -ld b2cint (Home Directory)
drwxr-xr-x   3 b2cint   custapp      512 Mar 11 11:05 b2cint

$ cd b2cint/.ssh

$ ls -ld ../.ssh
drwx------   2 b2cint   custapp      512 Mar 11 14:39 ../.ssh

$ ls -l
-rw-------   1 b2cint   custapp      332 Mar 11 14:39 authorized_keys
-rw-------   1 b2cint   custapp      332 Mar 11 14:38 authorized_keys2

But still it asks for a password.

Last edited by pludi; 03-12-2010 at 04:33 AM.. Reason: code tags, please...
Sponsored Links
    #5  
Old 03-12-2010
Registered User
 

Join Date: Dec 2009
Location: Dallas, TX
Posts: 80
Thanks: 1
Thanked 0 Times in 0 Posts
The source needs to have the id_rsa.pub key of the user that will be sending the file copied to the destination server user's home/.ssh/authorized_keys or authorized_keys2
Sponsored Links
    #6  
Old 03-16-2010
Registered User
 

Join Date: Jul 2005
Location: Chennai
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
It already has. I have already placed the contents of id_rsa.pub to authorized_keys2 file under $HOME/.ssh dir in the host.
Sponsored Links
    #7  
Old 03-16-2010
Moderator
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 12,191
Thanks: 232
Thanked 1,703 Times in 1,632 Posts
authorized_keys2 has been depreciated for 8 years now. Just cat all of them together into authorized_keys.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to write script that behaves both in interactive and non interactive mode rits Homework & Coursework Questions 8 08-17-2009 11:47 PM
Help with Interactive / Non Interactive Shell script rits Homework & Coursework Questions 1 08-16-2009 04:39 PM
SFTP - non-interactive - using passphrase sandy0077 Shell Programming and Scripting 1 10-11-2008 01:18 PM
SFTP Failed---Request for subsystem 'sftp' failed on channel 0 mahiban AIX 0 07-25-2008 02:51 AM
SFTP- Non-interactive user authentication dheeruchakri Shell Programming and Scripting 1 03-10-2006 11:14 AM



All times are GMT -4. The time now is 03:38 AM.