Unable to connect to SSH: "inputstream is closed"

Since a while ago I can't login to my SSH server for remote deployment. I think it happened after one of the latest updates of OpenSSH. However, every other SSH client I use doesn't seem to have any problem with it (like WinSCP or CLI ssh).

PhpStorm gives me both the error message "inputstream is closed" or "pipe closed".

2012-02-20 14:33:59,407 [ 304937]   INFO - ins.plugins.webDeployment.sftp - Connecting to php5 port 22
2012-02-20 14:33:59,409 [ 304939]   INFO - ins.plugins.webDeployment.sftp - Connection established
2012-02-20 14:33:59,429 [ 304959]   INFO - ins.plugins.webDeployment.sftp - Remote version string: SSH-2.0-OpenSSH_5.9
2012-02-20 14:33:59,429 [ 304959]   INFO - ins.plugins.webDeployment.sftp - Local version string: SSH-2.0-JSCH-0.1.44
2012-02-20 14:33:59,429 [ 304959]   INFO - ins.plugins.webDeployment.sftp - CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
2012-02-20 14:33:59,430 [ 304960]   INFO - ins.plugins.webDeployment.sftp - aes256-ctr is not available.
2012-02-20 14:33:59,430 [ 304960]   INFO - ins.plugins.webDeployment.sftp - aes192-ctr is not available.
2012-02-20 14:33:59,430 [ 304960]   INFO - ins.plugins.webDeployment.sftp - aes256-cbc is not available.
2012-02-20 14:33:59,430 [ 304960]   INFO - ins.plugins.webDeployment.sftp - aes192-cbc is not available.
2012-02-20 14:33:59,430 [ 304960]   INFO - ins.plugins.webDeployment.sftp - arcfour256 is not available.
2012-02-20 14:33:59,431 [ 304961]   INFO - ins.plugins.webDeployment.sftp - SSH_MSG_KEXINIT sent
2012-02-20 14:33:59,434 [ 304964]   INFO - ins.plugins.webDeployment.sftp - SSH_MSG_KEXINIT received
2012-02-20 14:33:59,434 [ 304964]   INFO - ins.plugins.webDeployment.sftp - kex: server->client aes128-ctr hmac-md5 none
2012-02-20 14:33:59,434 [ 304964]   INFO - ins.plugins.webDeployment.sftp - kex: client->server aes128-ctr hmac-md5 none
2012-02-20 14:33:59,447 [ 304977]   INFO - ins.plugins.webDeployment.sftp - SSH_MSG_KEXDH_INIT sent
2012-02-20 14:33:59,447 [ 304977]   INFO - ins.plugins.webDeployment.sftp - expecting SSH_MSG_KEXDH_REPLY
2012-02-20 14:33:59,469 [ 304999]   INFO - ins.plugins.webDeployment.sftp - ssh_rsa_verify: signature true
2012-02-20 14:33:59,469 [ 304999]   INFO - ins.plugins.webDeployment.sftp - Host 'php5' is known and mathces the RSA host key
2012-02-20 14:33:59,470 [ 305000]   INFO - ins.plugins.webDeployment.sftp - SSH_MSG_NEWKEYS sent
2012-02-20 14:33:59,470 [ 305000]   INFO - ins.plugins.webDeployment.sftp - SSH_MSG_NEWKEYS received
2012-02-20 14:33:59,470 [ 305000]   INFO - ins.plugins.webDeployment.sftp - SSH_MSG_SERVICE_REQUEST sent
2012-02-20 14:33:59,471 [ 305001]   INFO - ins.plugins.webDeployment.sftp - SSH_MSG_SERVICE_ACCEPT received
2012-02-20 14:33:59,479 [ 305009]   INFO - ins.plugins.webDeployment.sftp - Authentications that can continue: publickey,keyboard-interactive,password
2012-02-20 14:33:59,479 [ 305009]   INFO - ins.plugins.webDeployment.sftp - Next authentication method: publickey
2012-02-20 14:33:59,479 [ 305009]   INFO - ins.plugins.webDeployment.sftp - Authentications that can continue: password
2012-02-20 14:33:59,479 [ 305009]   INFO - ins.plugins.webDeployment.sftp - Next authentication method: password
2012-02-20 14:33:59,485 [ 305015]   INFO - ins.plugins.webDeployment.sftp - Authentication succeeded (password).
2012-02-20 14:33:59,557 [ 305087]   INFO - ins.plugins.webDeployment.sftp - Disconnecting from php5 port 22
2012-02-20 14:33:59,557 [ 305087]   INFO - ins.plugins.webDeployment.sftp - Caught an exception, leaving main loop due to socket closed
2012-02-20 14:33:59,558 [ 305088]   WARN - loyment.ui.WebServerConfigForm - Could not connect to SFTP server at "sftp://php5/".
org.apache.commons.vfs.FileSystemException: Could not connect to SFTP server at "sftp://php5/".
    at org.apache.commons.vfs.provider.sftp.SftpFileSystem.getChannel(SftpFileSystem.java:190)
    at org.apache.commons.vfs.provider.sftp.SftpFileObject.doListChildrenResolved(SftpFileObject.java:334)
    at org.apache.commons.vfs.provider.AbstractFileObject.getChildren(AbstractFileObject.java:633)
    at org.apache.commons.vfs.provider.AbstractFileObject.getChild(AbstractFileObject.java:743)
    at com.jetbrains.plugins.webDeployment.connections.RemoteConnectionPool.createConnection(RemoteConnectionPool.java:123)
    at com.jetbrains.plugins.webDeployment.connections.RemoteConnectionManager.openConnection(RemoteConnectionManager.java:105)
    at com.jetbrains.plugins.webDeployment.PublishUtils$1$1.run(PublishUtils.java:108)
    at com.intellij.openapi.application.impl.ApplicationImpl$6.run(ApplicationImpl.java:425)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
    at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:140)
Caused by: com.jcraft.jsch.JSchException: java.io.IOException: Pipe closed
    at com.jcraft.jsch.ChannelSftp.start(ChannelSftp.java:242)
    at com.jcraft.jsch.Channel.connect(Channel.java:200)
    at com.jcraft.jsch.Channel.connect(Channel.java:144)
    at org.apache.commons.vfs.provider.sftp.SftpFileSystem.getChannel(SftpFileSystem.java:143)
    ... 14 more
Caused by: java.io.IOException: Pipe closed
    at java.io.PipedInputStream.read(PipedInputStream.java:291)
    at java.io.PipedInputStream.read(PipedInputStream.java:361)
    at com.jcraft.jsch.ChannelSftp.fill(ChannelSftp.java:2333)
    at com.jcraft.jsch.ChannelSftp.header(ChannelSftp.java:2359)
    at com.jcraft.jsch.ChannelSftp.start(ChannelSftp.java:211)
    ... 17 more
2012-02-20 14:34:26,676 [ 332206]   INFO - api.vfs.impl.local.FileWatcher - 1 paths checked, 0 mapped, 5 mks
2012-02-20 14:34:32,875 [ 338405]   INFO - api.vfs.impl.local.FileWatcher - 0 paths checked, 0 mapped, 0 mks
2012-02-20 14:34:35,670 [ 341200]   INFO - ins.plugins.webDeployment.sftp - Connecting to php5 port 22
2012-02-20 14:34:36,705 [ 342235]   WARN - loyment.ui.WebServerConfigForm - Could not connect to SFTP server at "sftp://php5/".
org.apache.commons.vfs.FileSystemException: Could not connect to SFTP server at "sftp://php5/".
    at org.apache.commons.vfs.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:106)
    at org.apache.commons.vfs.provider.AbstractOriginatingFileProvider.getFileSystem(AbstractOriginatingFileProvider.java:103)
    at org.apache.commons.vfs.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:82)
    at org.apache.commons.vfs.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:66)
    at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:692)
    at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:620)
    at com.jetbrains.plugins.webDeployment.connections.RemoteConnectionPool.createConnection(RemoteConnectionPool.java:120)
    at com.jetbrains.plugins.webDeployment.connections.RemoteConnectionManager.openConnection(RemoteConnectionManager.java:105)
    at com.jetbrains.plugins.webDeployment.PublishUtils$1$1.run(PublishUtils.java:108)
    at com.intellij.openapi.application.impl.ApplicationImpl$6.run(ApplicationImpl.java:425)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
    at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:140)
Caused by: org.apache.commons.vfs.FileSystemException: Could not connect to SFTP server at "php5".
    at org.apache.commons.vfs.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:268)
    at org.apache.commons.vfs.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:95)
    ... 16 more
Caused by: com.jcraft.jsch.JSchException: Session.connect: java.net.ConnectException: Connection refused: connect
    at com.jcraft.jsch.Session.connect(Session.java:504)
    at com.jcraft.jsch.Session.connect(Session.java:154)
    at org.apache.commons.vfs.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:264)
    ... 17 more
2012-02-20 14:34:49,685 [ 355215]   INFO - ins.plugins.webDeployment.sftp - Connecting to php5 port 22
2012-02-20 14:34:49,688 [ 355218]   INFO - ins.plugins.webDeployment.sftp - Connection established
2012-02-20 14:34:49,704 [ 355234]   INFO - ins.plugins.webDeployment.sftp - Remote version string: SSH-2.0-OpenSSH_5.9
2012-02-20 14:34:49,704 [ 355234]   INFO - ins.plugins.webDeployment.sftp - Local version string: SSH-2.0-JSCH-0.1.44
2012-02-20 14:34:49,704 [ 355234]   INFO - ins.plugins.webDeployment.sftp - CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
2012-02-20 14:34:49,707 [ 355237]   INFO - ins.plugins.webDeployment.sftp - aes256-ctr is not available.
2012-02-20 14:34:49,707 [ 355237]   INFO - ins.plugins.webDeployment.sftp - aes192-ctr is not available.
2012-02-20 14:34:49,707 [ 355237]   INFO - ins.plugins.webDeployment.sftp - aes256-cbc is not available.
2012-02-20 14:34:49,707 [ 355237]   INFO - ins.plugins.webDeployment.sftp - aes192-cbc is not available.
2012-02-20 14:34:49,707 [ 355237]   INFO - ins.plugins.webDeployment.sftp - arcfour256 is not available.
2012-02-20 14:34:49,707 [ 355237]   INFO - ins.plugins.webDeployment.sftp - SSH_MSG_KEXINIT sent
2012-02-20 14:34:49,724 [ 355254]   INFO - ins.plugins.webDeployment.sftp - SSH_MSG_KEXINIT received
2012-02-20 14:34:49,724 [ 355254]   INFO - ins.plugins.webDeployment.sftp - kex: server->client aes128-ctr hmac-md5 none
2012-02-20 14:34:49,724 [ 355254]   INFO - ins.plugins.webDeployment.sftp - kex: client->server aes128-ctr hmac-md5 none
2012-02-20 14:34:49,738 [ 355268]   INFO - ins.plugins.webDeployment.sftp - SSH_MSG_KEXDH_INIT sent
2012-02-20 14:34:49,738 [ 355268]   INFO - ins.plugins.webDeployment.sftp - expecting SSH_MSG_KEXDH_REPLY
2012-02-20 14:34:49,763 [ 355293]   INFO - ins.plugins.webDeployment.sftp - ssh_rsa_verify: signature true
2012-02-20 14:34:49,764 [ 355294]   INFO - ins.plugins.webDeployment.sftp - Host 'php5' is known and mathces the RSA host key
2012-02-20 14:34:49,769 [ 355299]   INFO - ins.plugins.webDeployment.sftp - SSH_MSG_NEWKEYS sent
2012-02-20 14:34:49,769 [ 355299]   INFO - ins.plugins.webDeployment.sftp - SSH_MSG_NEWKEYS received
2012-02-20 14:34:49,769 [ 355299]   INFO - ins.plugins.webDeployment.sftp - SSH_MSG_SERVICE_REQUEST sent
2012-02-20 14:34:49,772 [ 355302]   INFO - ins.plugins.webDeployment.sftp - SSH_MSG_SERVICE_ACCEPT received
2012-02-20 14:34:49,778 [ 355308]   INFO - ins.plugins.webDeployment.sftp - Authentications that can continue: publickey,keyboard-interactive,password
2012-02-20 14:34:49,778 [ 355308]   INFO - ins.plugins.webDeployment.sftp - Next authentication method: publickey
2012-02-20 14:34:49,962 [ 355492]   INFO - ins.plugins.webDeployment.sftp - Authentication succeeded (publickey).
2012-02-20 14:34:50,036 [ 355566]   INFO - ins.plugins.webDeployment.sftp - Disconnecting from php5 port 22
2012-02-20 14:34:50,036 [ 355566]   INFO - ins.plugins.webDeployment.sftp - Caught an exception, leaving main loop due to socket closed
2012-02-20 14:34:50,065 [ 355595]   WARN - loyment.ui.WebServerConfigForm - Could not connect to SFTP server at "sftp://php5/".
org.apache.commons.vfs.FileSystemException: Could not connect to SFTP server at "sftp://php5/".
    at org.apache.commons.vfs.provider.sftp.SftpFileSystem.getChannel(SftpFileSystem.java:190)
    at org.apache.commons.vfs.provider.sftp.SftpFileObject.doListChildrenResolved(SftpFileObject.java:334)
    at org.apache.commons.vfs.provider.AbstractFileObject.getChildren(AbstractFileObject.java:633)
    at org.apache.commons.vfs.provider.AbstractFileObject.getChild(AbstractFileObject.java:743)
    at com.jetbrains.plugins.webDeployment.connections.RemoteConnectionPool.createConnection(RemoteConnectionPool.java:123)
    at com.jetbrains.plugins.webDeployment.connections.RemoteConnectionManager.openConnection(RemoteConnectionManager.java:105)
    at com.jetbrains.plugins.webDeployment.PublishUtils$1$1.run(PublishUtils.java:108)
    at com.intellij.openapi.application.impl.ApplicationImpl$6.run(ApplicationImpl.java:425)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
    at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:140)
Caused by: com.jcraft.jsch.JSchException: java.io.IOException: inputstream is closed
    at com.jcraft.jsch.ChannelSftp.start(ChannelSftp.java:242)
    at com.jcraft.jsch.Channel.connect(Channel.java:200)
    at com.jcraft.jsch.Channel.connect(Channel.java:144)
    at org.apache.commons.vfs.provider.sftp.SftpFileSystem.getChannel(SftpFileSystem.java:143)
    ... 14 more
Caused by: java.io.IOException: inputstream is closed
    at com.jcraft.jsch.ChannelSftp.fill(ChannelSftp.java:2335)
    at com.jcraft.jsch.ChannelSftp.header(ChannelSftp.java:2359)
    at com.jcraft.jsch.ChannelSftp.start(ChannelSftp.java:211)
    ... 17 more


It seems that it can establish a connection (I can also confirm this in the server logs) but after that it closes the connection.

Does anyone have a clue as to why this is happening?

0
8 comments
Avatar
Permanently deleted user

Update: I think this has something to do with the SFTP-server subsystem not running...

0

Does it work ok with PhpStorm v3.0.0 ?

Maybe, just maybe, it is the issue with jsch ? Try newer ( http://sourceforge.net/projects/jsch/files/jsch.jar/0.1.46/jsch-0.1.46.jar/download ) or older ( http://repo1.maven.org/maven2/com/jcraft/jsch/0.1.42/jsch-0.1.42.jar ) version of that library ( replace one that is present in PHPSTORM_INSTALL_FOLDER\plugins\webDeployment\lib\ )

0

Looks like same problem is described in this issue. Please follow Andriy's advice and write about result.

0
Avatar
Permanently deleted user

I now know what the problem was: the /dev/null was chmodded 0644 which resulted in some strange errors for normal users. So root was able to use sftp, but other uses received an error. chmodding /dev/null to 0666 resolved all issues.

And that wasted two hours of my life. I love computers! X-(

0
Avatar
Permanently deleted user

Thanks for sharing!!

0
Avatar
Permanently deleted user

I got this message when on login get any additinal messages (ex.: about some errors). But after clear login all ok.

0
Avatar
Permanently deleted user

I just ran into this myself -- or I think I did. I was alternately getting "Inputstream is closed" and "Pipe closed." I didn't check the PhpStorm log, but I got the following messages in my server's auth log:

Accepted publickey for [USER] from [IP] port 50088 ssh2
pam_unix(sshd:session): session opened for user [USER] by (uid=0)
subsystem request for sftp by user [USER]
channel_by_id: 0: bad id: channel free
Disconnecting: Received data for nonexistent channel 0.
pam_unix(sshd:session): session closed for user [USER]



Since it seems there actually is (or was) an error in JSch which caused this, I tried all versions of jsch from 0.1.42 - 0.1.48 but of course nothing worked.

I finally tracked it down to an incorrect path for the SFTP subsystem configured in /etc/ssh/sshd_config. After fixing the configuration, problem solved.

In my case, the server was Ubuntu 12.04, and the correct configuration was:
Subsystem    sftp    /usr/lib/openssh/sftp-server
0
Avatar
Permanently deleted user

@jason, what but exactly did you fix?

0

Please sign in to leave a comment.