1. 程式人生 > >sftp登入linux Received message too long (or "Bad packet length") 原因,已解決

sftp登入linux Received message too long (or "Bad packet length") 原因,已解決

sftp and scp2 both actually work by running sshin a subprocess, to connect to the remote host and run the file-transferserver (usually namedsftp-server). For instance, the commandsftp server might result in the following command beingrun (OpenSSH):

ssh server -s -oForwardX11=no -oForwardAgent=no -oProtocol=2 sftp

scp2/sftp and sftp-server use a special file-transferprotocol, which they speak over this SSH session. The protocol is in factbased on the same packet protocol used by SSH.

In order for this to work, the SSH session must be "clean" — that is,it must have on it only information transmitted by the programs at eitherend. What often happens, though, is that there are statements in eitherthe system or per-user shell startup files on the server(.bashrc

, .profile, /etc/csh.cshrc,.login, etc.) which output text messages on login, intended to beread by humans (likefortune, echo "Hi there!", etc.).Such code should only produce output on interactive logins, when there isa tty attached to standard input. If it does not make this test, it willinsert these text messages where they don't belong: in this case,polluting the protocol stream between scp2/sftp
andsftp-server. The first four bytes of the text gets interpretedas a 32-bit packet length, which will usually be a wildly large number,provoking the error message above. Notice that:

1416586337 decimal = 546F6461 hex = "Toda" ASCII

suggesting a string beginning "Today..." (or maybe "Thank-you" intransliterated Hebrew).

The reason the shell startup files are relevant at all, is that sshdemploys the user's shell when starting any programs on the user's behalf(using e.g./bin/sh -c "command"). This is a Unixtradition, and has advantages:

  • The user's usual setup (command aliases, environment variables,umask, etc.) are in effect when remote commands are run.
  • The common practice of setting an account's shell to/bin/false to disable it will prevent the owner from running anycommands, should authentication still accidentally succeed for somereason.
There has been a lot of argument about whether this is the right behavior,since havingsshd instead exec sftp-server directly,without the shell, would avoid this frequent problem. I personally feelthat using the shell is the right thing to do: having startup files thatemit text messages when there is no user to read them is just amistake.

SSH2 has a Boolean configuration statementAllowCshrcSourcingWithSubsystems, set false by default, whichcausessshd2 to pass the -f flag to the shell whenrunning subsystem programs (sftp-server is run as an SSH-2"subsystem"). With most shells,-f causes the shell to omit thenormal startup file processing. This prevents the corruption problem, butintroduces other difficulties. With file transfers, the umask setting isimportant, and people are confused when they find that the umask they setin their ~/.login file works with random remote commands(e.g. ssh server touch foo), but is mysteriously ignoredwhen using scp2/sftp.

Check your .bashrc and .bash_profile on the server, remove anything that can echo. For now, comment the lines out.

一句話,把bashrc,bash_profile所有帶echo的都去掉

相關推薦

sftp登入linux Received message too long (or "Bad packet length") 原因解決

sftp and scp2 both actually work by running sshin a subprocess, to connect to the remote host and run the file-transferserver (usually na

訊息佇列 mq_queue報錯: message too long

原因說明: 原因很簡單,要注意看LINUX man手冊,man 3 mq_receive裡明確說了,“The msg_len argument must be greater than or equal to the mq_msgsize attribute

Warning: Unable to send packet: Error with PF_PACKET send() [11]: Message too long (errno = 90)

今天在使用tcpreplay重放流量時,發現有的資料包沒有傳送成功: Warning: Unable to send packet: Error with PF_PACKET send() [215]: Message too long (errno = 90) Warn

java.lang.IllegalArgumentException:Short string too long;utf-8 encoded length=373,max=255

看到這個錯誤的 第一個想法就是傳送的訊息長度過長,經過上網查詢資料基本上沒有相關的問題,因為根本不是這個訊息太長 第二天跟蹤訊息原來是因為type的長度超過了255 昨天使用mq傳送訊息直接報錯字串太長 ,原來是因為BasicProperties bp = new AMQP.BasicP

mysql Data too long for column ‘xxx’ at row xxx的解決方法

java操作資料庫新增/修改資料時報錯  mysql Data too long for column ‘xxx’ at row xxx 這是編碼不統一問題:資料庫安裝的編碼 /  建立的表的編碼 /  表字段的編碼  /   java專案中hql/sql 編碼需要一致

Ubuntu 在登入使用者介面輸入正確密碼類似於復位重複讓我繼續輸入密碼進不去解決

在操作ubuntu作業系統的時候,我切換了tty到命令列介面(CTRL+ATL+F1),然後按startx切換回圖形介面,就發生瞭如上述題目的情況 解決:在嘗試了網上的各種方法,如: 1.清理系統 sudo apt-get autoremove   2.重灌桌面 sudo

laravel migrate時報錯:Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

今天在學習laravel的路由模型繫結時,在按照文件執行php artisan migrate時報錯。 In Connection.php line 664: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was

Linux 下rm刪除命令提示 /bin/rm: argument list too long解決辦法

       假設我們要刪除資料夾test,test下有很多檔案,如果我們使用rm ./test/* 命令進行刪除,則會出現/bin/rm: argument list too long無法刪除的報錯提示。 報錯提示原因:資料夾下的檔案數目過多,命令列過

Linux 問題 001:Argument list too long解決方法

要刪除test資料夾下以jpg結尾的檔案。 find test/ -name "*.jpg" | xargs -i rm {} 要拷貝test資料夾下以jpg結尾的檔案到train目錄。 fin

Linux執行命令報錯”Arg list too long”的原因分析

最近在SUSE LINUX作業系統中遇到個問題:在一個包含上萬個檔案的資料夾中執行rm *刪除所有檔案時報錯“Arg list too long”,最後導致刪除失敗。後來查了下資料,經過分析發現這裡有以下幾個技術點需要注意: 1. 在LINUX作業系統有限制單條命令列的長度是128KB,也就是131

Linux 底下 檔案過多導致 ls 命令出現 arguments too long 的問題

作為一個linux使用者/系統管理員, 有些時候你會遇到以下錯誤提示: [[email protected] foo]$ mv * ../foo2 bash: /bin/mv: Argument list too long “Argument list t

Laravel5 Syntax error or access violation: 1071 Specified key was too long; max key length is 1000

新建立了個laravel5框架,然後安裝laravel-admin並執行migration的時候出現瞭如下報錯問題  php artisan admin:install Migration table created successfully. In Connection.p

教你如何配置linux使用者實現禁止ssh登陸機器但可用sftp登入

構想和目標 最近有個這樣的訴求:基於對線上伺服器的保密和安全,不希望開發人員直接登入線上伺服器,因為登入伺服器的許可權太多難以管控,如直接修改程式碼、系統配置,並且也直接連上mysql。因此希望能限制開發人員ssh登入機器,但是通過ftp/sftp上傳程式碼檔案。 在

訊息佇列使用注意的地方(argument list too longlinux

Linux提供了一系列訊息佇列的函式介面來讓我們方便地使用它來實現程序間的通訊(IPC)。 本文不講詳細的使用,詳細請參考  http://blog.csdn.net/ljianhui/article

Linux rm 很多檔案出現/bin/rm: Argument list too long解決方法

本人由於不慎使用定時任務產生了很多垃圾檔案,刪除時出現/bin/rm: Argument list too long 最終在stackoverflow找到解決方法 執行以下指令碼迴圈刪除 for f in presstest?name*; do rm "$f";done

Linux中“Argument list too long解決方法

當我想執行以下命令時,報錯:mv train2014/* coco_train2014/ -bash: /bin/mv: Argument list too long這是因為這些命令的引數太長,即檔案個數過多。其中 train2014 資料夾的內容全是 .jpg 格式的圖片檔

Filename or extension too long, 提示文件名太長無法刪除或修改

字符 ref 分享圖片 發現 後來 一個 enter 當我 分享 從Linux端同步了一個文件到Windows系統,這個文件名非常長,超過了256個字符,當我要刪除其上層文件夾的時候才發現無法刪除,提示:Filename or extension too long, 我這才

導入轉儲文件的時候:Error Code: 1406. Data too long for column - MySQL

some sql_mod ict and query long switch oba -m MySQL will truncate any insert value that exceeds the specified column width. to make this

Linux server上too many open files問題

server bsp one 當前 java程序 clas gre work -h 之前測試遇到了"too many open files"的問題。ulimit -Hn 查了下發現server上最大open file數是4096。寫了個簡單的腳本檢測發現進程創建的fd個數在

Laravel 5.4 migrate時報錯: Specified key was too long error

code php pdo oot uniq ble defaults return utf8編碼 Laravel 5.4默認使用utf8mb4字符編碼,而不是之前的utf8編碼。因此運行php artisan migrate 會出現如下錯誤: [Ill