I recently tried to using sftp to access my linux box where I implement a simple shell of my own. And I set the users except root to use mine shell in default(by editing /etc/passwd
file). Then problem arise, once I tried to access through sftp, I will receive a message saying:
Received message too long
I searched for the solutions and one solution is to change the default shell for this user back to normal bash shell. I tried so and it worked, the problem is that is there a way that I can still using my own shell and also allow sftp to go through? Please answer me with more details like which file I should go editing, etc
Make sure you log in to your server's IP ADDRESS (not your domain) with the SYSTEM USER used to create your app; attempting to connect to your domain directly is one of the most common causes of SFTP connection failures. Make sure you attempt to connect over SFTP. ServerPilot does not support unsecure FTP connections.
When the AC functions as an SFTP server, run the display ssh server status command to check whether the SFTP service is enabled on the AC. If the SFTP service is disabled, run the sftp server enable command in the system view to enable the SFTP service on the SSH server.
Configure your server to use the internal sftp server adding the following directive to /etc/ssh/sshd_config
:
Subsystem sftp internal-sftp
That way, it will not use the user shell to launch the sftp server program.
"Received message too long" means that your SFTP client received bad data from the SFTP server. The typical reason is that the shell startup scripts on the server (.bashrc, .profile, .cshrc, etc.) are producing some output, and your SFTP client is trying to parse that output as an SFTP message. You can check this by running the command:
ssh user@remote 'echo hello'
If this produces any output other than the "hello", then that output would probably prevent SFTP or SCP from working properly.
As in salva's answer, you can avoid this by setting the SSH server to use internal-sftp for SFTP sessions. This avoids launching your shell for SFTP sessions. This won't help with SCP or with other programs like git or rsync which run through ssh.
The other ways to fix this is to go through your shell startup commands, figure out what is producing the output, and prevent that from happening during non-interactive SSH sessions. One tip is to test for a TTY before running commands which produce output:
if [ -t 1 ]; then
# standard output is a TTY
...
fi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With