I am using debian in my raspberry pi and Ubuntu12.04 in my laptop. I am trying to send some files from my raspberry pi to my laptop. For this I use SSH and use this command:-

sudo scp acc.c [email protected]:/home/

where acc.c is my .c file and is my laptop IP address. But using this command I got this error:-

ssh: connect to host port 22: Connection refused
lost connection

So, my first guess was that I am using SSH command in wrong way, so I decide to send some files from my laptop to raspberry pi(just to check if SSH working properly). For this I write this command:-

sudo scp abc.c  [email protected]:/home/

where is my raspberry pi IP address. On this I got this output:-

[email protected]'s password: 
scp: /home//abc.c: Permission denied

Although I am not able to send file from either side but I am getting different results from each side. So, please tell me how to send files from each side using SSH (specially from raspberry pi to my laptop) and why I am getting different outputs on each side.

UPDATE:- Now I can send file from laptop to raspberry pi but Still can't send file from raspberry pi to laptop

  • first of all, you don't have to sudo to run scp. Secondly, only root can write files to /home. I think what you mean is /home/pi. Try: scp abc.c [email protected]:
    – linuxgnuru
    Commented Jan 10, 2015 at 11:46
  • OK, I can transmit file from laptop to raspberry pi, But still I getting error in transmitting file from raspberry pi to laptop. I am using command :- scp acc.c [email protected]: and getting this output:- ssh: connect to host port 22:Connection refused lost connection Commented Jan 10, 2015 at 12:05
  • 1
    Is sshd running on the laptop?
    – linuxgnuru
    Commented Jan 10, 2015 at 13:44

3 Answers 3


You can also use the scp command to copy files from the remote location to your local computer. So you could do

scp [email protected]:~/acc.c ~/

If this also does not work check if you are the owner of both the local and remote directory and that you have read/write permissions.


"Connection refused" means there is nothing listening on the port. What's happening is ssh is looking for an ssh server on your laptop, but there isn't one.

The pi distros run sshd (the ssh server) by default because most people probably want that. But a standard linux desktop distro like you are using on your laptop probably was not configured this way, so if you want to be able to ssh into it from elsewhere (or use scp to it), then you need to configure and run sshd on the laptop. You'll also have to open port 22 if you use a firewall.


I had the same problem and was able to solve it as suggested by installing openssh-server on the Ubuntu laptop. Thx for the Q and help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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