- Linux scp connection refused
- Thread: scp command — connection refused
- scp command — connection refused
- Re: scp command — connection refused
- Re: scp command — connection refused
- Copy files from Linux to Windows
- 4 Answers 4
- scp connection refused error
- 6 Answers 6
- You must log in to answer this question.
- Related
- Hot Network Questions
- Subscribe to RSS
- Why am I getting a «port 22: Connection refused» error?
- 7 Answers 7
Linux scp connection refused
I wish to automate a daily activity of uploading a specific file to a specific location at mywebsite. On google searching I found scp is command to get my work done
but when I run scp I get following output.
scp myfile.pdf myusername@ftp.mywebsite.com:/Path/which/I/want/
ssh: connect to host ftp.mywebsite.com port 22: Connection refused
lost connection
Here I have deliberately changed my my username,website name and file path for security reason. In actual command I am using correct username, ftp server name and path.
Can anyone please help me find what is going wrong?
Most likely there is no SSH server running on the remote host, or on a different port number, or its blocked by a firewall.
— ping the machine (to test connectivety)
— see if there is a ssh deamon running
~$ ps -ef |grep sshd
root 457 1 0 07:32 ? 00:00:00 /usr/bin/sshd -D
— run the same command but add «-vvv» to get more verbose output.
edit: Just noticed you are connecting to «ftp.mywebsite.com». Most likely you can only use FTP to your site. Check with your hosting provider is SSH is available
Most likely there is no SSH server running on the remote host, or on a different port number, or its blocked by a firewall.
— ping the machine (to test connectivety)
— see if there is a ssh deamon running
~$ ps -ef |grep sshd
root 457 1 0 07:32 ? 00:00:00 /usr/bin/sshd -D
— run the same command but add «-vvv» to get more verbose output.
edit: Just noticed you are connecting to «ftp.mywebsite.com». Most likely you can only use FTP to your site. Check with your hosting provider is SSH is available
infocafe@devils-home:~/Desktop$ ping ftp.mywebsite.com
PING ftp.mywebsite.com (. ) 56(84) bytes of data.
64 bytes from ftp.mywebsite.com (. ): icmp_seq=1 ttl=46 time=271 ms
64 bytes from ftp.mywebsite.com (. ): icmp_seq=2 ttl=46 time=270 ms
64 bytes from ftp.mywebsite.com (. ): icmp_seq=3 ttl=46 time=271 ms
ps -ef |grep sshd
root 2685 1 0 21:09 ? 00:00:00 /usr/sbin/sshd -D
infocafe 14170 13431 0 21:52 pts/2 00:00:00 grep —color=auto sshd
scp -vvv myfilename.pdf myusername@ftp.mywebsite.com:/path/which/i/want/
Executing: program /usr/bin/ssh host ftp.mywebsite.com, user myusername, command scp -v -t /path/that/i/want/
OpenSSH_6.2p2 Ubuntu-6ubuntu0.1, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to ftp.mywebsite.com [. ] port 22.
debug1: connect to address . port 22: Connection refused
ssh: connect to host ftp.mywebsite.com port 22: Connection refused
lost connection
Thread: scp command — connection refused
A Carafe of Ubuntu
Join Date Sep 2011 Location Nasik, MH, India Beans 88 —> Beans 88 Distro Ubuntu 13.10 Saucy Salamander
scp command — connection refused
I wish to automate a daily activity of uploading a specific file to a specific location at mywebsite. On google searching I found scp is command to get my work done
but when I run scp I get following output.
scp myfile.pdf myusername@ftp.mywebsite.com:/Path/which/I/want/ ssh: connect to host ftp.mywebsite.com port 22: Connection refused lost connection
Here I have deliberately changed my my username,website name and file path for security reason. In actual command I am using correct username, ftp server name and path.
Can anyone please help me find what is going wrong?
Chocolate-Covered Ubuntu Beans
Re: scp command — connection refused
Most likely there is no SSH server running on the remote host, or on a different port number, or its blocked by a firewall.
— ping the machine (to test connectivety)
— see if there is a ssh deamon running
~$ ps -ef |grep sshd root 457 1 0 07:32 ? 00:00:00 /usr/bin/sshd -D
— run the same command but add «-vvv» to get more verbose output.
edit: Just noticed you are connecting to «ftp.mywebsite.com». Most likely you can only use FTP to your site. Check with your hosting provider is SSH is available
A Carafe of Ubuntu
Join Date Sep 2011 Location Nasik, MH, India Beans 88 —> Beans 88 Distro Ubuntu 13.10 Saucy Salamander
Re: scp command — connection refused
Originally Posted by justleen
Most likely there is no SSH server running on the remote host, or on a different port number, or its blocked by a firewall.
— ping the machine (to test connectivety)
— see if there is a ssh deamon running
~$ ps -ef |grep sshd root 457 1 0 07:32 ? 00:00:00 /usr/bin/sshd -D
— run the same command but add «-vvv» to get more verbose output.
edit: Just noticed you are connecting to «ftp.mywebsite.com». Most likely you can only use FTP to your site. Check with your hosting provider is SSH is available
infocafe@devils-home:~/Desktop$ ping ftp.mywebsite.com
PING ftp.mywebsite.com (. ) 56(84) bytes of data.
64 bytes from ftp.mywebsite.com (. ): icmp_seq=1 ttl=46 time=271 ms
64 bytes from ftp.mywebsite.com (. ): icmp_seq=2 ttl=46 time=270 ms
64 bytes from ftp.mywebsite.com (. ): icmp_seq=3 ttl=46 time=271 ms
ps -ef |grep sshd
root 2685 1 0 21:09 ? 00:00:00 /usr/sbin/sshd -D
infocafe 14170 13431 0 21:52 pts/2 00:00:00 grep —color=auto sshd
scp -vvv myfilename.pdf myusername@ftp.mywebsite.com:/path/which/i/want/
Executing: program /usr/bin/ssh host ftp.mywebsite.com, user myusername, command scp -v -t /path/that/i/want/
OpenSSH_6.2p2 Ubuntu-6ubuntu0.1, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to ftp.mywebsite.com [. ] port 22.
debug1: connect to address . port 22: Connection refused
ssh: connect to host ftp.mywebsite.com port 22: Connection refused
lost connection
Copy files from Linux to Windows
The firewall is disabled on Windows and Port 22 is open. I can connect via putty client to CentOS on that port. I’m quite confused here. Thanks.
obviously the first question I should ask is: is there a sshd running on the windows machine? which windows version?
I am using Windows 2012, but I would like this to work on Win10 as well. If there is a way, else I will fall back to winscp.
What are you using for SSH on the windows side? Sometimes Windows-based ssh will disable SCP. You may have to check the GUI on the windows side. Although it’s weird you would get «connection refused» which would indicate a TCP failure which should be affecting scp and ssh equally.
Can you putty SSH to the Windows machine on port 22? Usually when the error code is «Connection refused» no program is listening on port 22. Try netstat -a on the Windows machine to see if port 22 is listening.
Part of the confusion sounds like you’re not familiar with networks and protocols. curl isn’t telnet . Just because you’re using curl (a program that talks HTTP to web servers) to port 22 doesn’t make it suddenly start using a different protocol. Also, telnet is to port 23, so even if you did have telnet it would still be wrong because you really need something that uses the ssh protocol.
4 Answers 4
The fact that you can initiate a connection from the windows box to the Linux box does in no way imply that the reverse is possible as well.
If you want to be able to scp to your Windows machine, you need to make sure you have a SSH service running on your Windows machine which allows for incoming ssh connections. The fact that you get a ‘connection refused’ message suggests that that isn’t set up or the service is not started.
Since you share that you’ve been able to reach your Linux machine using ssh, it’s probably easier to just turn things around, and run scp on the Windows machine instead.
scp connection refused error
I am trying to transfer a file from linux server to macosx machine using scp . scp test username@68.120.23.91:~/ 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.
6 Answers 6
Connection refused, if not the firewall, often indicates that the ssh service is not running on the remote computer.
on the remote computer will verify if it’s running or not — IF you can somehow access that remote box.
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.
Try installing openssh-client and openssh-server on your target computer if Linux. Otherwise the suitable ssh server for your Operating System.
If your ssh connection uses a specific port, set it for scp as well with
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.
root@123.456.789.123'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.
Connection refused lost connection
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.
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Why am I getting a «port 22: Connection refused» error?
error while connecting to a server. I have both the openssh client and server installed, and they are running. But still there is an error. Please help.
According to me , Configure firewall such that it allows to ssh (port 22 ) which is currently blocked by firewall.
7 Answers 7
I went through this issue and finally got appropriate answer.
sudo apt-get update sudo apt-get install openssh-server sudo ufw allow 22
Then went into raspi-config in a terminal window and enabled ssh.
This will allow port 22 to be used for sshd.
Performed the first three lines on both computers and the file is now successfully transferred. Why does Ubuntu not come with these installed/enabled by default? The connection refused error is so cryptic, I had no idea if it was a firewall issues, username issue, IP address issue, etc etc. Very frustrating.
While on the server, check to make sure sshd is actually running, and is listening on port 22:
$ sudo netstat -anp | grep sshd tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1538/sshd tcp6 0 0 . 22 . * LISTEN 1538/sshd
If you don’t get results, or they don’t show you’re listening on tcp 0.0.0.0:22. fix that.
If you DO show that sshd is running and is listening on tcp port 22, check to make sure there’s no firewall rule getting in the way. Again, on the server:
$ sudo iptables -L | grep ssh DROP tcp -- anywhere anywhere tcp dpt:ssh
$ sudo ufw verbose Status: active To Action From -- ------ ---- 22 DENY Anywhere 22/tcp DENY Anywhere
If you do see a rule like one of the ones above, you’ll need to fix that.
If you don’t see any firewall rules in the way and you do see the service running on the server, then it’s time to check your workstation, and the network it’s connected to. Can you connect to other servers? Can you ping your own interface or loopback address? Etc.