Getting "Received too large SFTP packet" when logging in with Root using WinSCP to Google Compute Engine virtual machine instance
Asked Answered
U

11

15

Hi I can login to the GCE VM with WinSCP using my own username, cannot login as root...this is by default according to Google, and can be changed.

Changed like this:

Step 1: Login SSH and Su Root

# sudo su root

Step 2: Change password Root

#passwd root

Step 3: Config SSHD allow Root login

#nano /etc/ssh/sshd_config
PermitRootLogin yes
PasswordAuthentication yes

#service sshd restart (I used ssh as I'm using ubuntu and sshd wouldn't work)

Tried to login as root via WinSCP but I get

"Received too large (1349281121 B) SFTP packet. Max supported packet size is 1024000 B. The error is typically caused by message printed from startup script (like .profile). The message may start with 'Plea'." Cannot initialize SFTP protocol. Is the host running a SFTP server?"

Any ideas?

Urbanna answered 29/10, 2015 at 8:28 Comment(1)
Got the error when trying to log on to a newly created AWS EC2 instance. The solution was to use the admin username instead of root. The Plea thing turned out to be a message asking Please login as the user "admin" rather than the user "root".Safeguard
U
2

Hmmm, I added this in WinSCP in advanced settings under "protocol options": sudo /usr/lib/openssh/sftp-servers

I can login with my own username and move files now. Although not exactly sure how this works, I think it somehow changes you to root user at login?

More info: https://winscp.net/eng/docs/faq_su

Urbanna answered 29/10, 2015 at 8:53 Comment(1)
This works for Ubuntu 18.04 as well, just has to drop last 's': sudo /usr/lib/openssh/sftp-server not '..servers'Sidesman
M
21

Received too large SFTP packet. Max supported packet size is 102400 B

Cause: This problem can arise when your .bashrc file is printing data to the screen (e.g.archey, screenfetch). The .bashrc file runs every time any console shell is initialized.

enter image description here

Solution: Simply move any scripts that generate output from your .bashrc file to your .bash_profile. The .bash_profile only runs when you create a physical shell session.

Mouthy answered 9/5, 2016 at 16:9 Comment(3)
You're right; note that any 'echo' command in your profile may cause the problem. To resolve this, comment any kind of 'echo' in your .bashrc file and reconnect the session.Codd
i fall back to SCP, why shouldn't WinSCP just ignore that printing, hard to dig it out from .bashrc /etc/bashrc /etc/profile, etc. many of themSodality
Thank you so much. I added an echo statement to my .bashrc and it prevented Transmit for Mac from connecting to my Amazon Linux EC2 instance. In case anybody runs into the same issue I had. (Error simply was "Can't connect")Sextans
P
14

NOTE: Just for anyone who comes across this and simply wants to copy files and doesn't matter what file protocol they use. You can just switch file protocol from SFTP to SCP to avoid this issue. Thought it might be worth a mention.

Pointing answered 17/5, 2016 at 9:30 Comment(1)
tks, using SCP works, but im still receiving the error and my .bashrc /etc/bashrc... are not printing out anythingSodality
S
4

If you used Ubuntu linux and try to connect the server then "Please login as the Ubuntu user" you should sftp as the ubuntu user, not as root.

Try that, hope it will work for you!

Thanks!

Sluiter answered 22/7, 2017 at 13:16 Comment(1)
Same problem when switching from CentOS 6 to 7, it used to work with root, but not anymore. SSH attempt with root responsed with Please login as the user "centos" rather than the user "root". Changing user in WinSCP solved it.Stuccowork
U
2

Hmmm, I added this in WinSCP in advanced settings under "protocol options": sudo /usr/lib/openssh/sftp-servers

I can login with my own username and move files now. Although not exactly sure how this works, I think it somehow changes you to root user at login?

More info: https://winscp.net/eng/docs/faq_su

Urbanna answered 29/10, 2015 at 8:53 Comment(1)
This works for Ubuntu 18.04 as well, just has to drop last 's': sudo /usr/lib/openssh/sftp-server not '..servers'Sidesman
H
1

Disbale Ubuntu Welcome message for any user logged via SSH:

sudo chmod -x /etc/update-motd.d/*

Secondly, you'll be facing Error Code 1 that is to be solved by creating somefile (without ~ and . in its name) in dir /etc/sudoers.d/ with a line:

user1 ALL=NOPASSWD: /usr/bin/su -c /usr/lib/openssh/sftp-server

Granting user1 a permission to connect to server via SFTP as SuperUser without promting for sudo password. Of course, don't forget to run sudo systemctl restart sshd afterwards.

After that in advanced connection settings of WinSCP you can specify in SFTP tab:

sudo su -c /usr/lib/openssh/sftp-server

So you'll be able to write to protected files/folders.

Hulky answered 21/6, 2023 at 1:47 Comment(0)
U
1

Ensure you can login with the user ie to check this run

cat /ect/passwd

the user should not have :/sbin/nologin

Unsightly answered 10/11, 2023 at 16:21 Comment(0)
M
0

See WinSCP article on Received too large (... B) SFTP packet. Max supported packet size is 102400 B

If … (from the subject [error message]) is a very large number then the problem is typically caused by a message printed from some profile/logon script. It violates an SFTP protocol. Some of these scripts are executed even for non-interactive (no TTY) sessions, so they cannot print anything (nor ask user to type something).

Mannish answered 29/10, 2015 at 9:3 Comment(1)
I didn't try this as adding "sudo /usr/lib/openssh/sftp-servers" in WinSCP advanced setting worked. Thanks.Urbanna
S
0

To add to @ThatOneCoder's answer on the cause being too much output from .bashrc: in e.g. Ubuntu, there is also the system wide /etc/bash.bashrc that might be "too wordy" and cause the Received too large SFTP packet error.

It's a "system wide .bashrc", and if you want to execute code for all logging in, that's one location to place it. If you nixed ~/.bashrc and still get the error, check the contents of /etc/bash.bashrc.

Shanell answered 5/11, 2021 at 16:51 Comment(0)
I
0

It is happening because you haven't given shell access permission to the user.

Inquest answered 20/9, 2022 at 22:48 Comment(2)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Orvilleorwell
Actually this answer give me a good hint!Gilli
M
0

I could not make it work editing .bashrc, .proline etc, but I finally made sftp login work by editing the /etc/passwd file. There, the shell was set to "sbin/nologin" for the sftp-user, and changing it to "/bin/bash" fixed it

Mceachern answered 18/6 at 12:58 Comment(0)
G
-2

I faced the same issue trying to login on my ubuntu 16.04 EC2 server as "root" via WinSCP. I spent a lot of time trying to fix it but in the end a simple workaround worked for me.

I ssh into the instance using PuTTY with the username "ubuntu". After this I typed

sudo -i

and with this the user was changed to root.

Giliane answered 5/4, 2019 at 15:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.