New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid packet exception ssh'ing as root when "Please login as the ubuntu user rather than root user" #75

Closed
aledsage opened this Issue May 19, 2012 · 8 comments

Comments

Projects
None yet
3 participants
@aledsage
Contributor

aledsage commented May 19, 2012

I have an ubuntu VM that I'm trying to use with the following code:

   public static void main(String[] args) throws IOException {
      String privateKey = "<snip>";
      net.schmizz.sshj.SSHClient ssh = new net.schmizz.sshj.SSHClient();
      ssh.addHostKeyVerifier(new PromiscuousVerifier());
      ssh.connect("54.247.147.118", 22);

      OpenSSHKeyFile key = new OpenSSHKeyFile();
      key.init(privateKey, null);
      ssh.authPublickey("root", key);

      SFTPClient sftpClient = ssh.newSFTPClient();
   }

It gives me the error:

Exception in thread "main" java.lang.IllegalStateException: Invalid packet: indicated length 1349281121 too large
    at net.schmizz.sshj.sftp.PacketReader.readPacket(PacketReader.java:70)
    at net.schmizz.sshj.sftp.SFTPEngine.init(SFTPEngine.java:77)
    at net.schmizz.sshj.SSHClient.newSFTPClient(SSHClient.java:623)
    at org.jclouds.sshj.Main.main(Main.java:42)

Trying to ssh or scp to the machine at the command line with:

ssh -i my_id_rsa root@54.247.147.118

gives:

Please login as the ubuntu user rather than root user.
Connection to 54.247.147.118 closed.

It works when I ssh in as:

ssh -i my_id_rsa ubuntu@54.247.147.118

Is there some different behaviour of the ssh protocol in this situation?

@aledsage

This comment has been minimized.

Show comment
Hide comment
@shikhar

This comment has been minimized.

Show comment
Hide comment
@shikhar

shikhar May 20, 2012

Contributor

Thanks for the report @aledsage , it's odd that there is different behaviour with the openssh client & with sshj. I will try to reproduce what's going on.

Contributor

shikhar commented May 20, 2012

Thanks for the report @aledsage , it's odd that there is different behaviour with the openssh client & with sshj. I will try to reproduce what's going on.

@shikhar

This comment has been minimized.

Show comment
Hide comment
@shikhar

shikhar May 20, 2012

Contributor

Could you post what you get with

sftp -i my_id_rsa root@54.247.147.118

(sftp command instead of ssh)

Contributor

shikhar commented May 20, 2012

Could you post what you get with

sftp -i my_id_rsa root@54.247.147.118

(sftp command instead of ssh)

@shikhar

This comment has been minimized.

Show comment
Hide comment
@shikhar

shikhar May 20, 2012

Contributor

So I tried this out, even openssh sftp client bails out...

$ sftp -i sshjaws.pem root@xxxx.compute-1.amazonaws.com
Received message too long 1349281121

So it's not an sshj issue

Contributor

shikhar commented May 20, 2012

So I tried this out, even openssh sftp client bails out...

$ sftp -i sshjaws.pem root@xxxx.compute-1.amazonaws.com
Received message too long 1349281121

So it's not an sshj issue

@shikhar shikhar closed this May 20, 2012

@aledsage

This comment has been minimized.

Show comment
Hide comment
@aledsage

aledsage May 20, 2012

Contributor

Confirmed I get the same with sftp -oIdentityFile=my_id_rsa root@54.247.147.118, gives:

Connecting to 54.247.147.118...
Received message too long 1349281121
Contributor

aledsage commented May 20, 2012

Confirmed I get the same with sftp -oIdentityFile=my_id_rsa root@54.247.147.118, gives:

Connecting to 54.247.147.118...
Received message too long 1349281121
@aledsage

This comment has been minimized.

Show comment
Hide comment
@aledsage

aledsage May 20, 2012

Contributor

For the benefit of anyone searching for more information on this....

This link explains what's going on in openssh sftp: http://www.snailbook.com/faq/sftp-corruption.auto.html

The problem here is similar to if the underlying ssh command causes stdout (e.g. due to system or per-user shell startup files on the server). The text pollutes the protocol stream between scp2/sftp and sftp-server. The first four bytes of the text gets interpreted as a 32-bit packet length.

Contributor

aledsage commented May 20, 2012

For the benefit of anyone searching for more information on this....

This link explains what's going on in openssh sftp: http://www.snailbook.com/faq/sftp-corruption.auto.html

The problem here is similar to if the underlying ssh command causes stdout (e.g. due to system or per-user shell startup files on the server). The text pollutes the protocol stream between scp2/sftp and sftp-server. The first four bytes of the text gets interpreted as a 32-bit packet length.

@shikhar

This comment has been minimized.

Show comment
Hide comment
@shikhar

shikhar May 20, 2012

Contributor

That's a good explanation, thanks @aledsage

Contributor

shikhar commented May 20, 2012

That's a good explanation, thanks @aledsage

@stringaro-leo

This comment has been minimized.

Show comment
Hide comment
@stringaro-leo

stringaro-leo Feb 14, 2016

@aledsage '...(like fortune, echo "Hi there!", etc.)....' you saved me, thx

stringaro-leo commented Feb 14, 2016

@aledsage '...(like fortune, echo "Hi there!", etc.)....' you saved me, thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment