Getting “Received too large SFTP packet” when logging in with Root using WinSCP to Google Compute Engine virtual machine instance

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-17 19:12:38

问题


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?


回答1:


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.

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.




回答2:


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.




回答3:


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!




回答4:


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




回答5:


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).




回答6:


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.



来源:https://stackoverflow.com/questions/33409233/getting-received-too-large-sftp-packet-when-logging-in-with-root-using-winscp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!