4

I am trying to transfer a file from linux server to macosx machine using scp.

scp test [email protected]:~/

it shows error

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

I checked firewall settings on mac it allows all connections from all machine. Please help me asap.

Let me know if you need any other information.

2
  • Is sshd up and running?
    – Dave G
    Mar 25, 2011 at 18:31
  • Have you tried ssh -vvv test [email protected]:~/ ? This will give you more info on the error.
    – mooreds
    Mar 25, 2011 at 18:35

6 Answers 6

6

Connection refused, if not the firewall, often indicates that the ssh service is not running on the remote computer.

Running

ps -aux | grep sshd

on the remote computer will verify if it's running or not - IF you can somehow access that remote box.

2
  • 2
    yes, sudo apt install openssh-server immediately solved the problem. Thanks. Feb 18, 2021 at 9:48
  • I wish I could upvote Yan's response, that was the answer in my case as well.
    – cdahms
    Oct 24, 2021 at 15:39
1

On the Mac, go to System Preferences > Sharing and make sure Remote Login is enabled (checked).

Also, shouldn't you have escaped the ~ in that scp command? Otherwise I'm afraid your local (Linux) shell will swallow it and replace it with the path to your Linux account's home directory.

0

Try installing openssh-client and openssh-server on your target computer if Linux. Otherwise the suitable ssh server for your Operating System.

0

If your ssh connection uses a specific port, set it for scp as well with

scp -P 1234 <other params>
0

Check whether you are logged in as root which is often needed to reach a protected folder on the server. User root is not allowed in scp.

[email protected]'s password:
Permission denied, please try again.

Instead, on the server and logged in as root, copy the file to an unprotected folder like /tmp. Then exit the root user or scp from outside and use scp with a normal user, not root.

Then you avoid:

Connection refused 
lost connection
0

Check that you use the right IP, the one from the remote.

I made the mistake to copy and paste the wrong IP, name wlp0s20f3, from the wrong list of IPs, a list that I had taken from my own machine, using ip a, although I should have taken the other output list of the remote machine instead. Since I mixed this up, I took an IP that simply did not allow me to enter, and it would not have helped anyway since it was from the same machine.

You must log in to answer this question.