anchor.diff:  
   (defmethod stream-write-byte ((stream ssh-channel-stream-output) byte)
     (with-slots (output-pos output-size output-buffer) stream
  -	  (if (>= output-size (length output-buffer))
  -		  (stream-finish-output* stream :dont-send-eof t))
  -	  (when (< output-size (length output-buffer))
  -		(prog1
  -			(setf (aref output-buffer output-size) byte)
  -		  (incf output-size 1)))))
  +    (if (>= output-size (length output-buffer))
  +      (stream-finish-output* stream :dont-send-eof t))
  +    (when (< output-size (length output-buffer))
  +    (prog1
  +      (setf (aref output-buffer output-size) byte)
  +      (incf output-size 1)))))
   
   (defmethod stream-write-char ((stream ssh-channel-stream-output) char)
     (stream-write-byte stream (char-code char)))
  
positive.code: 
  (defun  throw-last-error (session)
    (multiple-value-bind (message code)
  	  (session-last-error session)
  	(error 'ssh-generic-error
  		   :message message
  		   :code    code)))
  
  (defmacro with-last-error ((session error-type) &rest args)
    `(multiple-value-bind (message code)
  	   (session-last-error ,session)
  	 (error (quote ,error-type)
  			:message message
  			:code    code
  			,@args)))
  
  (defclass auth-data ()
    ((login    :type      string
  			 :initarg   :login
  			 :initform  ""
  			 :reader    login)))
  
  (defclass ssh-connection ()
    ((session     :type     +session+
  				:initarg  :session
  				:initform (null-pointer)
  				:reader   session)
     (socket      :type     usocket:socket
  				:initarg  :socket
  				:accessor socket)
     (host        :type     string
  				:initarg  :host
  				:accessor host)
     (port        :type     int
  				:initarg  :port
  				:accessor port)
     (hosts-db    :type     string
  				:initarg  :hosts-db
  				:accessor hosts-db)
     (auth-passed :type     boolean
  				:initform nil
  				:accessor auth-passed)))
  
  (define-condition ssh-handshake-error (ssh-generic-error) ())
  
  (define-condition ssh-bad-hostkey (error)
    ((reason :type      +check-verdict+
  		   :accessor  reason
  		   :initarg   :reason)
     (hash   :type      string
  		   :accessor  hash
  		   :initarg   :hash)))
  
  (defmethod create-ssh-connection (host (hosts-db string)
  								  &key
  								  (port 22)
  								  (read-timeout 5)
  								  (write-timeout 5))
    (let ((new-session nil)
  		(new-socket  nil)
  		(retval      :error-none))
  	(unwind-protect
  		 (progn
  		   (setq new-session (session-init))
  		   (setq new-socket (usocket:socket-connect host port))
  		   (set-timeouts new-socket read-timeout write-timeout)
  		   (session-set-blocking new-session :blocking)
  
  		   (setq retval
  				 (session-handshake new-session (usocket-get-fd new-socket)))
  
  		   (if (eq retval :error-none)
  			   (make-instance 'ssh-connection
  							  :session  new-session
  							  :socket   new-socket
  							  :host     host
  							  :port     port
  							  :hosts-db hosts-db)
  			   (throw-last-error new-session)))
  	  (unless (eq retval :error-none)
  		(unless (null-pointer-p new-session)
  		  (session-free new-session))
  		(unless (null new-socket)
  		  (usocket:socket-close new-socket))
  		nil))))
  
  
  (defmethod destroy-ssh-connection ((ssh ssh-connection) &key (description "") (lang ""))
  
negative.code: 
  (defmethod stream-read-byte ((stream ssh-channel-stream-input))
    (cond
    ((< (input-pos stream) (input-size stream))
     (prog1 (elt (input-buffer stream) (input-pos stream))
       (incf (input-pos stream))))
    (t (progn
       (multiple-value-bind (amount eof)
         (channel-read (channel stream)
                 (input-buffer stream))
         (if eof :eof
           (progn
           (setf (input-pos   stream)  1)
           (setf (input-size  stream)  amount)
           (elt  (input-buffer stream) 0))))))))
  
  ;; Looks like libssh2 sends 0 byte as EOF. Crazy shit :]
  (defmethod stream-read-sequence ((stream ssh-channel-recv) thing start end &key)
    (multiple-value-bind (start eof)
      (call-next-method)
    (values
     (- start (if (and (> start 0)
               eof)
            1 0))
     eof)))
  
  (defmethod stream-read-sequence ((stream ssh-channel-stream-input) thing start end &key)
    (let ((request-size (- end start)))
    (with-slots (channel input-size input-buffer input-pos) stream
      (labels
        ((buffer-to-output ()
         (let* ((buffered-portion-size (- input-size input-pos ))
            (replaced-size (min buffered-portion-size request-size)))
           (when (> replaced-size 0)
           (replace thing input-buffer
                :start1 start     :end1 (+ start
                             replaced-size)
                :start2 input-pos :end2 (+ input-pos
                             replaced-size))
           (incf input-pos    replaced-size)
           (incf start        replaced-size)
           (decf request-size replaced-size))))
  
         (fill-buffer-and-output ()
         (multiple-value-bind (amount eof)
           (channel-read channel input-buffer)
  
           (setf input-size amount)
           (setf input-pos  0)
  
           (buffer-to-output)
           (unless (or (= request-size 0) eof)
           (fill-buffer-and-output)))))
  
      (buffer-to-output)
      (when (> request-size 0)
        (fill-buffer-and-output))
      (values
       start
       (channel-eofp channel))))))
  
  (defmethod stream-read-line ((stream ssh-channel-stream-input))
    (let ((output '()))
    (labels
      ((repeat-not-wait ()
         ;; Search for new line in cached tail
         (let* ((nl-pos (position (char-code '#\Newline)
                    (input-buffer stream)
                    :start (input-pos  stream)
                    :end   (input-size stream)))
            (co-end (if nl-pos nl-pos (input-size stream))))
         ;; Save substring or whole vector if any
         (when (> (input-size stream) 0)
           (push (subseq (input-buffer stream)
                 (input-pos stream)
                 co-end)
             output))
  
         (if nl-pos
           ;; If newline found - save position and return concatenated string
           (prog1
             (babel:octets-to-string
              (apply #'concatenate
                 (cons '(VECTOR
                     (UNSIGNED-BYTE
                      8))
                     (reverse output))))
             (setf (input-pos stream) (+ 1 co-end))
             (setf output '()))
  
           ;; If not - try to catch next portion
           (multiple-value-bind (amount eof)
             (channel-read (channel stream) (input-buffer stream))
             (cond
             ((not eof)
              (progn
              (setf (input-pos  stream) 0)
              (setf (input-size stream) amount)
              (repeat-not-wait)))
             (t
              (if (not (null output))
                ;; Return last cached data
                (let ((result
                   (babel:octets-to-string
                    (apply #'concatenate
                       (cons '(VECTOR
                           (UNSIGNED-BYTE
                            8))
                           (reverse output))))))
                (setf (input-size stream) 0
                    (input-pos  stream) 0)
                (setf output '())
                (values result t))
                ;; Time to return nil
                (values nil t)))))))))
      (repeat-not-wait))))
  
  (defmethod stream-force-output ((stream ssh-channel-stream-output))
    (with-slots (channel output-buffer output-pos output-size) stream
    (let ((amount 0))
      (when (> output-size 0)
      (setq amount (channel-write channel
                    output-buffer
                    :start output-pos
                    :end   output-size))
      (incf output-pos amount))
      (if (= output-pos
         output-size)
        (setf output-pos  0
          output-size 0 ))
      amount)))
  
  (defmethod stream-force-output ((stream ssh-channel-stream))
    0)
  
  (defmethod stream-finish-output* ((stream ssh-channel-stream-output) &key (dont-send-eof nil))
    (with-slots (socket channel output-buffer output-pos output-size) stream
    (let ((amount 0))
      (when (> output-size 0)
      (setq amount
          (channel-write channel
                 output-buffer
                 :start output-pos
                 :end   output-size))
      (incf output-pos amount)
      (if (= output-pos
           output-size)
        (setf output-pos  0
            output-size 0 )))
  
      (if dont-send-eof
        amount
        (channel-send-eof channel)))))
  
  (defmethod stream-finish-output ((stream ssh-channel-stream-output))
    (stream-finish-output* stream))
  