Scp in terminal to copy something from my laptop to a server

  • Thread starter Thread starter Silviu
  • Start date Start date
  • Tags Tags
    Laptop Server
Click For Summary

Discussion Overview

The discussion revolves around using the SCP (Secure Copy Protocol) command to transfer files from a laptop to a server. Participants are troubleshooting issues related to connection refusals and the correct syntax for specifying the port number in the SCP command.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Exploratory

Main Points Raised

  • One participant reports difficulty using the SCP command and receives a "Connection refused" error when attempting to connect on port 22.
  • Another participant suggests checking SSH connectivity to the server before using SCP.
  • A participant confirms successful SSH connection but notes the need to specify a non-default port (4410) for SCP.
  • Several participants propose using the verbose option (-v) with SCP to diagnose issues.
  • There is confusion regarding the correct placement of the port specification (-P) in the SCP command, with multiple participants providing input on the correct syntax.
  • Participants clarify that the port number must be specified before the source file in the SCP command.
  • One participant expresses confusion about the command format and whether they are correctly specifying the destination path.
  • Another participant emphasizes the importance of including the destination path in the command to avoid defaulting to port 22.

Areas of Agreement / Disagreement

There is no consensus on the resolution of the issue, as participants are providing differing suggestions and clarifications without a definitive solution being reached.

Contextual Notes

Participants are working with varying levels of familiarity with SCP and SSH commands, leading to potential misunderstandings about command syntax and options.

Silviu
Messages
612
Reaction score
11
Hi I need to copy something from my laptop to a server. I tried using scp filename servername but it didn't work. I asked someone and he said I have to use -P but I don't know how. I tried several ways but all of them give
port 22: Connection refused. What can I do?
Thank you!
 
Computer science news on Phys.org
check to see if you can ssh into the device first.
$ ssh username@ip-address

are you able to successfully ssh into the device?
 
Routaran said:
check to see if you can ssh into the device first.
$ ssh username@ip-address

are you able to successfully ssh into the device?

NEW

Yes, I am able to connect, but I need to use ssh -p 4410 username@ip-address. I tried using -P and 4410 in scp command but it still didn't work.
 
Try the following
$ scp -vP 4410 username@ip-addr:/path/to/file .

I added the verbose option, hopefully we see where it's going wrong
 
Routaran said:
Try the following
$ scp -vP 4410 username@ip-addr:/path/to/file .

I added the verbose option, hopefully we see where it's going wrong
Wait, so in this, where I specify the file I want to send, before or after -vP 4410? (I want to send the file from my computer to username@ip...)
 
In that case
scp -vP 4410 /path/on/your/computer username@ip-addr:/destination/path/on/remote/system/
 
Routaran said:
In that case
scp -vP 4410 /path/on/your/computer username@ip-addr:/destination/path/on/remote/system/
I get this
usage: scp [-12346BCEpqrv] [-c cipher] [-F ssh_config] [-i identity_file]

[-l limit] [-o ssh_option] [-P port] [-S program]

[[user@]host1:]file1 ... [[user@]host2:]file2
 
can you show me the command you are typing in?
 
Routaran said:
can you show me the command you are typing in?

scp -vP 89418.txt username@ip-adr (username and ip-adr are the same i use for the ssh command which is working)
 
  • #10
You have to specify the port number before the text file.

scp -vP 4410 89418.txt username@ip-adr
 
  • #11
Routaran said:
You have to specify the port number before the text file.

scp -vP 4410 89418.txt username@ip-adr
You mean 4410? Isn't is already before the text file?
 
  • #12
yes, you didn't have it in your post.
 
  • #13
Routaran said:
yes, you didn't have it in your post.
Sorry I am a bit confused. What do you mean
 
  • #14
Silviu said:
scp -vP 89418.txt username@ip-adr (username and ip-adr are the same i use for the ssh command which is working)
The command you are using does not specify a destination port number. As a result, scp is using the default ssh port 22.

Your command:
scp -vP 89418.txt username@ip-adr

Correct command
scp -vP 4410 89418.txt username@ip-adr:/path/to/destination/folder/
 
  • #15
Routaran said:
The command you are using does not specify a destination port number. As a result, scp is using the default ssh port 22.

Your command:
scp -vP 89418.txt username@ip-adr

Correct command
scp -vP 4410 89418.txt username@ip-adr:/path/to/destination/folder/
Oh, sorry I have that I just didn't add show it here. I have the /path/to/destination/folder/ part
 
  • #16
That is the correct format and should work. What is the debug output from the command?
 

Similar threads

  • · Replies 11 ·
Replies
11
Views
986
  • · Replies 24 ·
Replies
24
Views
3K
Replies
4
Views
2K
  • · Replies 20 ·
Replies
20
Views
16K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 15 ·
Replies
15
Views
6K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K