Passwordless SFTP - Can connect from server A to B; but vise-versa not happening


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Passwordless SFTP - Can connect from server A to B; but vise-versa not happening
# 1  
Old 03-28-2016
Passwordless SFTP - Can connect from server A to B; but vise-versa not happening

Hi,

I am trying to execute password less SFTP between two servers A &B. While I was able to connect B from A; I am not able to connect the A from B.
I have done done similar steps for both scenarios:
  1. Creating public key using "ssh-keygen -t rsa".
  2. Appending the content to "authorized_keys" file.
  3. making sure .ssh directory has 700 permission and "authorized_keys" file has 600 permission.
Please help me to find whats wrong I am doing here.


File permission of Server A
Code:
A:pts/1:/home/mnand504/.ssh 355>ls -lart
total 128
drwxrwxr-x  19 mnand504   users         8192 Mar 24 06:12 ..
-rw-r--r--   1 mnand504   users            0 Mar 24 06:16 abc.txt
-rw-r--r--   1 mnand504   users          399 Mar 28 01:21 id_rsa.pub_MJ
-rw-------   1 mnand504   users          399 Mar 28 01:29 id_rsa.pub
-rw-------   1 mnand504   users         1679 Mar 28 01:29 id_rsa
-rw-r--r--   1 mnand504   users          444 Mar 28 01:30 known_hosts
drwx------   2 mnand504   users         8192 Mar 28 01:34 .
-rw-------   1 mnand504   users          399 Mar 28 01:35 authorized_keys

File permission of server B
Code:
/home/mnand504/.ssh
B->ls -lart
total 112
drwxrwxr-x   3 mnand504   users         8192 Mar 24 06:11 ..
-rw-r--r--   1 mnand504   users            0 Mar 24 06:14 abc.txt
-rw-r--r--   1 mnand504   users          888 Mar 28 01:22 known_hosts
drwx------   2 mnand504   users         8192 Mar 28 01:30 .
-rw-------   1 mnand504   users          798 Mar 28 01:30 authorized_keys
-rw-------   1 mnand504   users         1679 Mar 28 01:33 id_rsa
-rw-------   1 mnand504   users          399 Mar 28 01:33 id_rsa.pub

# 2  
Old 03-28-2016
Are both hosts using authorized_keys? try copying authorized_keys to authorized_keys2
# 3  
Old 03-28-2016
Is sshd running on A?
# 4  
Old 03-28-2016
If A has SELinux enabled, check the file labels on ~/.ssh and ~/.ssh/authorized_keys, they should read as ssh_home_t, for example
Code:
$ ls -lZa /home/hergp/.ssh
drwx------. hergp admin unconfined_u:object_r:ssh_home_t:s0 .
drwx------. hergp admin unconfined_u:object_r:user_home_dir_t:s0 ..
-rw-------. hergp admin unconfined_u:object_r:ssh_home_t:s0 authorized_keys
-rw-r--r--. hergp admin unconfined_u:object_r:ssh_home_t:s0 config
-rw-r--r--. hergp admin unconfined_u:object_r:ssh_home_t:s0 known_hosts

Also, your home directory must not be group or world writable.
# 5  
Old 03-28-2016
I came across a system where I had to change /etc/ssh/sshd_config file and specify
Code:
PubkeyAuthentication yes
 PermitEmptyPasswords yes

otherwise passwordless login would fail
# 6  
Old 03-29-2016
You should avoid having group write on your how directory as this is a security hole (someone in group "users" could rename .ssh and create their own fake one).

If B has "strictmode" set on the sshd server it will refuse to allow pubkey auth. You should have strictmode set on A as well to avoid possible security issues.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Connect direct - SFTP - List of servers that I can connect

Greetings Experts, I am working for a bank client and have a question on connect-direct and SFTP. We are using Linux RedHat servers. We use connect-direct to transfer (NDM) files from one server to another server. At times, we manually transfer the files using SFTP from one server to another... (2 Replies)
Discussion started by: chill3chee
2 Replies

2. UNIX for Beginners Questions & Answers

How to use passwordless sftp in script?

Hi I am trying to do SFTP in shell script in such a way that it should not ask for password. for this is use below script but it prompt for password. here I am not abled to understand where I am making mistake. #!/bin/bash # SFTP TO remote server USER="ITO" PASSWORD="abcd@1234"... (4 Replies)
Discussion started by: scriptor
4 Replies

3. Windows & DOS: Issues & Discussions

Passwordless sftp connection from UNIX to windows server

HI , I am trying to make a passwordless sftp connection from a unix server to windows server I have used a existing script which is like this cd /home150/adm/.ssh/ ssh-agent /usr/bin/ksh <<EOF ssh-add IDBNEWKEY ssh-add -l sftp IDBUSER@abc.com cd /home/IDBUSER/Share/IDB/ rm ${FILE}... (0 Replies)
Discussion started by: Jcpratap
0 Replies

4. HP-UX

Connect to remote server using sftp with password define within command/script

I am trying to connect to remote server in hp-ux, using sftp command (using sftp username@ip and password ) able to connect to remote server but, in this case sftp prompt for password and user need to manually enter it. I want sftp can read a password define in script or from file, so it can... (1 Reply)
Discussion started by: ketanraut
1 Replies

5. Solaris

Passwordless sftp issue

Hello Experts, I am trying to setup passwordless sftp from one of linux box to solaris box. I have generated key-pair and below is the permissions of the respective files. drwx------. 2 sftpuser sftpuser 4096 Dec 17 23:57 .ssh drwx------. 2 sftpuser sftpuser 4096 Dec 17 23:57 .... (16 Replies)
Discussion started by: sai_2507
16 Replies

6. IP Networking

How to transfer files from UNIX server to windows machine or vice versa using ftp or sftp commands?

hi, i want to write a shell script code which transfers files from a directory in unix server to a directory in a windows machine.. can any1 give me a sample code which uses ftp or sftp command.. thanks very much, (3 Replies)
Discussion started by: Little
3 Replies

7. Shell Programming and Scripting

passwordless sftp with debug options

Hi, In our project we already have a passwordless sftp with -b (batchfile) option working but there have been some new application rolled out at the client site and they want us to raise the DEBUG option somebody suggested to use following options with sftp command -oLogLevel=DEBUG... (4 Replies)
Discussion started by: dips_ag
4 Replies

8. Shell Programming and Scripting

passwordless authentication of SFTP script

Dear All I need to discuss about the problem which has been discussed so many times here. I need to transfer a file from server A to server B via passwordless SFTP script. By reading the threads on this topic here, I followed the below steps but still it's not working .. Pls find the steps... (13 Replies)
Discussion started by: uday.shankar
13 Replies

9. Shell Programming and Scripting

Passwordless SFTP

Hi, When Iam trying to do SFTP it is asking for password everytime. Can I have any alternative where I can provide the password in script itself. Because there are some control-M jobs which runs without user interaction. So please let me know the script where we can provide the password in the... (2 Replies)
Discussion started by: manneni prakash
2 Replies

10. Shell Programming and Scripting

how to connect sftp server using script

Hi friend I have a command: sftp -v dtxsttp90102@dtx.us.dell.com I need to connect sftp server using above command and grep for some files and need to back to script can anyone tell me how to write script connectingSFTP.sh -------------------- sftpCmd=`sftp -v... (1 Reply)
Discussion started by: kittusri9
1 Replies
Login or Register to Ask a Question