Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: scp command - connection refused

  1. #1
    Join Date
    Sep 2011
    Location
    Nasik, MH, India
    Beans
    83
    Distro
    Ubuntu 13.10 Saucy Salamander

    Question 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.

    Code:
    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?

    thanks in advance.

  2. #2
    Join Date
    Mar 2006
    Location
    Nerderlands
    Beans
    1,348
    Distro
    Ubuntu

    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
    Code:
    ~$ 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
    Last edited by justleen; January 21st, 2014 at 05:16 PM.
    "Please choose a different password, the one you have chosen is in use by UID 1432"

  3. #3
    Join Date
    Sep 2011
    Location
    Nasik, MH, India
    Beans
    83
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: scp command - connection refused

    Quote Originally Posted by justleen View Post
    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
    Code:
    ~$ 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
    ping

    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

  4. #4
    Join Date
    Nov 2008
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: scp command - connection refused

    Do you have a firewall running?
    Ubuntu Forums Moderation Staff
    The best people in life are free - T.S.

  5. #5
    Join Date
    Sep 2011
    Location
    Nasik, MH, India
    Beans
    83
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: scp command - connection refused

    How do I check it? I think I have ufw installed. One more thing- When I connect to my website using filezilla it is using a different port no- not port no 22

  6. #6
    Join Date
    Mar 2006
    Location
    Nerderlands
    Beans
    1,348
    Distro
    Ubuntu

    Re: scp command - connection refused

    the ps -ef |grep sshd, did you do that on your local machine, or on the remote? (should be remote)
    Do you have shell access at all to that machine, or just FTP access?

    I'm pretty confident the remote side is not accepting connections on port 22 / ssh..
    "Please choose a different password, the one you have chosen is in use by UID 1432"

  7. #7
    Join Date
    Sep 2011
    Location
    Nasik, MH, India
    Beans
    83
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: scp command - connection refused

    My web host have given me ftp user name and ftp address. By remote machine you mean server of webhost? I can not run that command on server. Is there any else way to check it? If, like you say, ssh is not enabled on remote machine and only ftp option is available then what is command that I can use to achieve my goal- automate uploading a file to a ftp address using linux commandline.

  8. #8
    Join Date
    Oct 2010
    Location
    Sweden
    Beans
    681
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: scp command - connection refused

    I'm just curious, do you have an ssh key set up?

    I have an scp script that connect to my host set up as:

    Code:
    
    scp -P 18765 -r ~/Pictures/Phoca_upload/* username@host.com:public_html/destination/directory
    My host uses port 18765 and I have a key in my ~/.ssh directory and a corresponding key on the server.
    Last edited by GrouchyGaijin; January 21st, 2014 at 05:48 PM. Reason: clarified comment
    Thank you,
    GG -----------
    GUI we don't need no stinking GUI: A collection of Bash scripts
    Mutt (email), cmus (music),Google Calendar and Google Tasks cli

  9. #9
    Join Date
    Sep 2011
    Location
    Nasik, MH, India
    Beans
    83
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: scp command - connection refused

    To be honest I do not understand these protocols and have no knowledge about networking and these file transfer protocols. I really do not know whether I am using correct command or not. I am using filezilla every day to get my work done. I quick connect with filezilla and manually upload the file to desired address. I wish to automate the job by creating a bash script. So I Googled and found scp command. I do not know if that command is the correct command in the scenario or not.

  10. #10
    Join Date
    Sep 2011
    Location
    Nasik, MH, India
    Beans
    83
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: scp command - connection refused

    What I have is a ftp username, a ftp server address. What command I may use to automate the same task of file transfer as I have a fixed file name with fixed local path and fixed remote path?

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •