Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I started a guest vm with

qemu-system-x86_64 -net user -net nic -redir tcp:10022::22 -m 500 -hda op.img

From the guest, I'm able to ssh the host machine, but can't connect via sftp The command I use for ssh is

ssh -R 10022:localhost:22 user@

Tried to play with sftp -oBindAddress and also -P, but with no success.

share|improve this question
What happens if you try sftp? What error messages do you get? What's the tracec from sftp -vvv? What ssh daemon are you running inside the guest, does it include sftp-server? – Gilles Feb 3 '12 at 23:05
@Gilles, the guest is an OpenBSD system. In sshd_config, sftp seems to be working as a Subsystem sftp /usr/libexec/sftp-server (same line as in host sshd_config. Maybe I'm not issuing the correct command, but can't find out how: $ sftp -vvv -oBindAddress=21222 user@ OpenSSH_5.9p1, OpenSSL 0.9.8r 8 Feb 2011 debug1: Reading configuration data /home/user/.ssh/config debug1: Reading configuration data /etc/ssh/ssh_config debug2: ssh_connect: needpriv 0 debug1: Connecting to [] port 22. Couldn't read packet: Connection reset by peer – Luis Feb 4 '12 at 16:41

If you can ssh to it, you can sftp to it. It's the same port right? You can check it with a tcpdump on your interfaces, you will see the "sftp" command making noise on your guest.

Go deeper by looking in your log files (/var/log/) especially /var/log/auth.log with tail -f while you are trying to log in.

I don't get why you are using this command to connect via ssh to your guest. What you are doing is telling ssh to listen and forward traffic arriving on your guest's port 10022 to port 22.

Just do:

ssh user@

assuming is your VM. To use sftp just do:

sftp user@

If the first works and not the second, it's a configuration problem, I guess. Provide us with more input if the problem persists.

share|improve this answer
from <alien.slackbook.org/dokuwiki/doku.php?id=slackware:qemu>;, QEMU will act as a firewall between guest OS and the host computer, so that no network communication is possible from any host program to the guest OS. For instance, you will not be able to setup a ssh session to the guest. – Luis Feb 4 '12 at 17:02
using sftp on the port 10022 doesn't work? I didn't really focus on the user mode and redir, but just on the issue making ssh working and sftp not working. You are able to ssh from the guest to the host but not use sftp, which is really not normal assuming an openssh-server running with the default configuration. Sorry I got messed up in my answer, and I'll let someone else carry on since I can't be of much help. – Aki Feb 4 '12 at 19:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.