We help IT Professionals succeed at work.

How to verify if SFTP is enabled in a UNIX box .

FranklinRaj22
on
Hi,

I am trying to establish a connection via SFTP from a UNIX to a ip and I get the below error . The ip is valid and the firewall is also opened up from the ip . Is there a way to identify if there is an issue in the source UNIX box .

java.net.SocketException: Connection timed out:could be due to invalid address
com.jcraft.jsch.JSchException: java.net.SocketException: Connection timed out:co
uld be due to invalid address
Comment
Watch Question

ps -ef | grep ftp should tell you if it's running.  I'd expect to see sftpd or ftpd or similar.

You should also be able to telnet to the port.  Also, since it's complaining about the address rather than the port (though it does show as a socket exception), check that the address itself is reachable via ping or traceroute.  

It's unlikely that the issue is in the source box.  Check basic networking though by trying external websites (or websites on the same domain as you're trying to ftp to).
CERTIFIED EXPERT
Top Expert 2007
Commented:
StuWhitby, sftp doesn't run as a daemon, it is a sub-system of ssh.

Try connecting on the command line rather than through your Java app, eg:

sftp user@ip
CERTIFIED EXPERT
Top Expert 2007

Commented:
Can you login to the unix server? if yes then:

the server ip is ok, and if you use ssh then you should not have a problem using sftp since it runs on the same port of ssh.

If you are able to login to the unix server by some other means, then try this command from command prompt on the unix box

sftp 0

if you can not reach the unix box then it could be a network issue. It could be routing. check routing on your system and on the unix box.
Gerwin Jansen, EE MVETopic Advisor
CERTIFIED EXPERT
Most Valuable Expert 2016

Commented:
Just checking whether sftp is 'enabled' is just a matter of typing 'sftp' on from a shell prompt. What kind of UNIX do you have btw? Are you able to connect to the ip address from your UNIX box using 'telnet' for example? Try 'telnet <ip address>' and 'ping <ip address>' to see if your destination is reachable.
svcs -a|grep sshd
CERTIFIED EXPERT
Top Expert 2007

Commented:
hossamshaaban, no mention of Solaris was made anywhere in this thread.

Additionally, having sshd running, doesn't mean the sftp subsystem is enabled.

Also, having sshd running on your local server doesn't have any bearing on whether you can connect to a remote server.
sftp is inserted module in SSH, so when SSH is enabled SFTP should be enabled also by default.
CERTIFIED EXPERT
Top Expert 2007

Commented:
SFTP is only enabled if it is defined in /etc/ssh/sshd_config, eg:

Subsystem sftp /usr/lib/openssh/sftp-server
yes, that  mean and i think my reply show that and this line is exist by default.
Gerwin Jansen, EE MVETopic Advisor
CERTIFIED EXPERT
Most Valuable Expert 2016

Commented:
@FranklinRaj22 - Any progress from your side worth mentioning?