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

In summary, 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?
  • #1
Silviu
624
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
  • #2
check to see if you can ssh into the device first.
$ ssh username@ip-address

are you able to successfully ssh into the device?
 
  • #3
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.
 
  • #4
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
 
  • #5
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...)
 
  • #6
In that case
scp -vP 4410 /path/on/your/computer username@ip-addr:/destination/path/on/remote/system/
 
  • #7
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
 
  • #8
can you show me the command you are typing in?
 
  • #9
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?
 

1. How do I use the SCP command to copy a file from my laptop to a server?

To copy a file from your laptop to a server using SCP, you can use the following command: scp [file_name] [server_username]@[server_ip]:[destination_path]. Replace [file_name] with the name of the file you want to copy, [server_username] with the username of the server, [server_ip] with the IP address of the server, and [destination_path] with the path where you want to save the file on the server.

2. Do I need to have special permissions to use SCP in the terminal?

Yes, you will need to have permission to access the server and the correct permissions to copy files to it. This typically involves having the correct username and password, or having a public key set up for authentication.

3. Can I use SCP to copy multiple files at once?

Yes, you can use the -r flag to recursively copy an entire directory and all of its contents to the server. For example: scp -r [directory_name] [server_username]@[server_ip]:[destination_path].

4. Will using SCP in the terminal overwrite existing files on the server?

Yes, by default, SCP will overwrite existing files on the server if the names are the same. However, you can use the -n flag to prevent overwriting and the -u flag to only copy files that are newer on the server than on your local machine.

5. Is there a way to track the progress of the file transfer when using SCP in the terminal?

Yes, you can use the -v flag to enable verbose mode, which will provide updates on the progress of the file transfer. You can also use the -P flag to specify a port number for the transfer, which can help with troubleshooting if the transfer is interrupted.

Similar threads

  • Computing and Technology
Replies
20
Views
3K
  • Computing and Technology
Replies
1
Views
2K
  • Programming and Computer Science
Replies
7
Views
488
  • Computing and Technology
Replies
15
Views
4K
Replies
2
Views
1K
  • Computing and Technology
Replies
5
Views
1K
  • Computing and Technology
4
Replies
123
Views
15K
  • Computing and Technology
Replies
15
Views
2K
  • Computing and Technology
Replies
15
Views
1K
  • Computing and Technology
Replies
5
Views
3K
Back
Top