diff -aur openssh-4.0p1.orig/sftp.c openssh-4.0p1/sftp.c
--- openssh-4.0p1.orig/sftp.c	2005-03-01 10:16:48.000000000 +0000
+++ openssh-4.0p1/sftp.c	2005-03-15 23:15:55.942262504 +0000
@@ -103,6 +103,7 @@
 #define I_SYMLINK	21
 #define I_VERSION	22
 #define I_PROGRESS	23
+#define I_APPEND	24
 
 struct CMD {
 	const char *c;
@@ -110,6 +111,7 @@
 };
 
 static const struct CMD cmds[] = {
+	{ "ap",		I_APPEND },
 	{ "bye",	I_QUIT },
 	{ "cd",		I_CHDIR },
 	{ "chdir",	I_CHDIR },
@@ -189,6 +191,7 @@
 	printf("mkdir path                    Create remote directory\n");
 	printf("progress                      Toggle display of progress meter\n");
 	printf("put local-path [remote-path]  Upload file\n");
+	printf("ap local-path [remote-path]   Upload and append file\n");
 	printf("pwd                           Display remote working directory\n");
 	printf("exit                          Quit sftp\n");
 	printf("quit                          Quit sftp\n");
@@ -569,7 +572,7 @@
 }
 
 static int
-process_put(struct sftp_conn *conn, char *src, char *dst, char *pwd, int pflag)
+process_put(struct sftp_conn *conn, char *src, char *dst, char *pwd, int pflag, int append)
 {
 	char *tmp_dst = NULL;
 	char *abs_dst = NULL;
@@ -629,7 +632,7 @@
 			abs_dst = make_absolute(tmp, pwd);
 
 		printf("Uploading %s to %s\n", g.gl_pathv[i], abs_dst);
-		if (do_upload(conn, g.gl_pathv[i], abs_dst, pflag) == -1)
+		if (do_upload(conn, g.gl_pathv[i], abs_dst, pflag, append) == -1)
 			err = -1;
 	}
 
@@ -897,6 +900,7 @@
 	switch (cmdnum) {
 	case I_GET:
 	case I_PUT:
+	case I_APPEND:
 		if (parse_getput_flags(&cp, pflag))
 			return(-1);
 		/* Get first pathname (mandatory) */
@@ -1032,7 +1036,8 @@
 		err = process_get(conn, path1, path2, *pwd, pflag);
 		break;
 	case I_PUT:
-		err = process_put(conn, path1, path2, *pwd, pflag);
+	case I_APPEND:
+		err = process_put(conn, path1, path2, *pwd, pflag, cmdnum==I_APPEND);
 		break;
 	case I_RENAME:
 		path1 = make_absolute(path1, *pwd);
diff -aur openssh-4.0p1.orig/sftp-client.c openssh-4.0p1/sftp-client.c
--- openssh-4.0p1.orig/sftp-client.c	2004-12-06 11:43:43.000000000 +0000
+++ openssh-4.0p1/sftp-client.c	2005-03-15 23:15:55.944262200 +0000
@@ -976,7 +976,7 @@
 
 int
 do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
-    int pflag)
+    int pflag, int append_file)
 {
 	int local_fd, status;
 	u_int handle_len, id, type;
@@ -1029,7 +1029,10 @@
 	buffer_put_char(&msg, SSH2_FXP_OPEN);
 	buffer_put_int(&msg, id);
 	buffer_put_cstring(&msg, remote_path);
-	buffer_put_int(&msg, SSH2_FXF_WRITE|SSH2_FXF_CREAT|SSH2_FXF_TRUNC);
+	if (append_file)
+		buffer_put_int(&msg, SSH2_FXF_WRITE|SSH2_FXF_CREAT|SSH2_FXF_APPEND);
+	else
+		buffer_put_int(&msg, SSH2_FXF_WRITE|SSH2_FXF_CREAT|SSH2_FXF_TRUNC);	
 	encode_attrib(&msg, &a);
 	send_msg(conn->fd_out, &msg);
 	debug3("Sent message SSH2_FXP_OPEN I:%u P:%s", id, remote_path);
diff -aur openssh-4.0p1.orig/sftp-client.h openssh-4.0p1/sftp-client.h
--- openssh-4.0p1.orig/sftp-client.h	2004-12-06 11:45:54.000000000 +0000
+++ openssh-4.0p1/sftp-client.h	2005-03-15 23:15:55.945262048 +0000
@@ -92,8 +92,8 @@
 
 /*
  * Upload 'local_path' to 'remote_path'. Preserve permissions and times
- * if 'pflag' is set
+ * if 'pflag' is set. Append instead of truncate if append_file is set.
  */
-int do_upload(struct sftp_conn *, char *, char *, int);
+int do_upload(struct sftp_conn *, char *, char *, int, int);
 
 #endif
diff -aur openssh-4.0p1.orig/sftp-server.c openssh-4.0p1/sftp-server.c
--- openssh-4.0p1.orig/sftp-server.c	2004-07-17 04:07:42.000000000 +0000
+++ openssh-4.0p1/sftp-server.c	2005-03-15 23:15:55.946261896 +0000
@@ -94,6 +94,10 @@
 	} else if (pflags & SSH2_FXF_WRITE) {
 		flags = O_WRONLY;
 	}
+	if ((pflags & SSH2_FXF_WRITE) &&
+	    (pflags & SSH2_FXF_APPEND)) {
+		flags |= O_APPEND;
+	}
 	if (pflags & SSH2_FXF_CREAT)
 		flags |= O_CREAT;
 	if (pflags & SSH2_FXF_TRUNC)
