Discuss (FTP) and (SFTP, FTPS and SCP), our Java file transfer clients.
no avatar
User

sachin4921

Posts

15

Joined

Mon Nov 05, 2012 6:10 pm

Changing the remote port for SFTP

by sachin4921 » Wed May 13, 2015 2:57 pm

no avatar
User

EDT Support

Posts

905

Joined

Mon Apr 26, 2004 3:03 pm

Re: Changing the remote port for SFTP

by EDT Support » Wed May 13, 2015 3:34 pm

Hi

It's likely that two different servers are accepting connections from the two ports. Either that or it's two differently configured sites on the same server. I recommend checking the server logs or asking the server administrators to do so.

- Hans (EnterpriseDT)
no avatar
User

sachin4921

Posts

15

Joined

Mon Nov 05, 2012 6:10 pm

Re: Changing the remote port for SFTP

by sachin4921 » Wed May 13, 2015 3:45 pm

Hi Hans,
Sorry i forgot to tell you one thing that when i tried sftp command using command prompt at
49222 port, it connected.

Reply to your post:
I got that checked earlier itself,
Both 22 and 49222 ports were open for SSH on the server machine.
So where ever i had tested the code, had both these ports open.
Connection mechanism was only using your library's connect method
of sshftpclient. Remote port was hard coded to 49222.

Second test i did to i disabled default port #22 on one of servers and only 49222 was open for SSH.
Still it din't work.
no avatar
User

EDT Support

Posts

905

Joined

Mon Apr 26, 2004 3:03 pm

Re: Changing the remote port for SFTP

by EDT Support » Wed May 13, 2015 3:50 pm

Actually I just realized that it's the client that's rejecting the server rather than the server rejecting the client. This means that my first reply is incorrect. The client is rejecting the server because it doesn't recognize its public key. Command-line ssh is probably working because it already knows the public key of the server from previous connections (they're stored in the known_hosts file).

To fix this you need to let SSHFTPClient know what it should expect the server's public key (i.e. the host key) to be. Please have a look for information about how you can use a known_hosts file to do this.

- Hans (EnterpriseDT)
no avatar
User

sachin4921

Posts

15

Joined

Mon Nov 05, 2012 6:10 pm

Re: Changing the remote port for SFTP

by sachin4921 » Wed May 13, 2015 4:24 pm

no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

Re: Changing the remote port for SFTP

by support2 » Thu May 14, 2015 12:53 am

The port number can also be used in known_hosts. Open a support ticket and send us your known_hosts file.
no avatar
User

sachin4921

Posts

15

Joined

Mon Nov 05, 2012 6:10 pm

Re: Changing the remote port for SFTP

by sachin4921 » Fri May 15, 2015 6:05 pm

I got the reason.
I was using two different redhat machines where different versions of ssh were configured.
on Red hat 6+, port number is also inserted along with hostname into known_host file
<hostname:portnumber> <alg> <key> ..

On Red hat 5.4, there was no port inserted into this known_hosts file with hostname.

So its working on redhat 6+ machines
no avatar
User

EDT Support

Posts

905

Joined

Mon Apr 26, 2004 3:03 pm

Re: Changing the remote port for SFTP

by EDT Support » Fri May 15, 2015 6:12 pm

Excellent. Thanks for letting us know.

- Hans (EnterpriseDT)

Who is online

Users browsing this forum: No registered users and 24 guests

Powered by phpBB ® | phpBB3 Style by KomiDesign
cron