• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Search

scp

GCP gcloud compute scp

January 31, 2022

Here’s how to download/upload files using gcloud compute scp.

Make sure you are authenticated.

gcloud auth login

gcloud auth login

How to download.

gcloud compute scp --recurse your-server:/home/username/yaml.tar.gz . \
--project your-project-id \
--zone us-central1-a \
--internal-ip

gcloud compute scp --recurse your-server:/home/username/yaml.tar.gz . \ --project your-project-id \ --zone us-central1-a \ --internal-ip

How to upload.

gcloud compute scp --recurse yaml.tar.gz your-server:/home/username/ \
--project your-project-id \
--zone us-central1-a \
--internal-ip

gcloud compute scp --recurse yaml.tar.gz your-server:/home/username/ \ --project your-project-id \ --zone us-central1-a \ --internal-ip

Filed Under: Cloud Tagged With: compute, download, files, gcloud, scp, upload

SCP with a Key

October 22, 2020

SCP is a secure copy utility in Linux. You’ll need access to your system. In this example, a pem key is used to authenticate to a host. SCP copies filename.ext to the home directory of ec2-user. It’s important to add the target directory, otherwise it will not work.

Here’s how to use SCP with a key from local to server.

scp -i key.pem filename.ext user@server:/home/user

scp -i key.pem filename.ext user@server:/home/user

From server to local. Run the command from local machine.

scp user@server:/home/user/file.txt /local/directory

scp user@server:/home/user/file.txt /local/directory

Filed Under: Linux Tagged With: copy, ec2-user, key, pem, scp

SCP

January 6, 2020

SCP is similar to the CP or copy command, but it’s done via a secure network.

Here’s a CP command.

cp /dir1/filename /dir2

cp /dir1/filename /dir2

You can use SCP to copy file to another system. It requires login.

scp /dir1/filename user@server:/home/user

scp /dir1/filename user@server:/home/user

This is using SCP to copy a file from 2 remote systems.

scp user@host1:/home/user/dir1/file.txt user@host2:/home/user/dir2

scp user@host1:/home/user/dir1/file.txt user@host2:/home/user/dir2

Filed Under: Linux Tagged With: cp, ftp, login, network, scp, secure

Secure Copy

December 30, 2016

If you’re logged in to a server via SSH, you can securely copy a file using SCP command tool or also known as “secure copy” to your local desktop, and vice versa. SCP uses SSH for data transfer, authentication and security. Here are several examples on how to use the SCP command line tool if you would like to securely transfer a file to and from your server. You’ll be asked for the user’s password for authentication.

Examples

# Copy the file "foobar.txt" from a remote host to the local host
$ scp username@remotehost.com:foobar.txt /your/local/directory
# Copy the file "foobar.txt" from the local host to a remote host
$ scp foobar.txt username@remotehost.com:/some/remote/directory

# Copy the file "foobar.txt" from a remote host to the local host $ scp username@remotehost.com:foobar.txt /your/local/directory # Copy the file "foobar.txt" from the local host to a remote host $ scp foobar.txt username@remotehost.com:/some/remote/directory

The downside of using SCP is that it is slow. It has been known to be slow. Here’s a quote from Spikelab’s blog.

SCP and the underlying SSH2 protocol implementation in OpenSSH is network performance limited by statically defined internal flow control buffers. These buffers often end up acting as a bottleneck for network throughput of SCP, especially on long and high bandwidth network links.

Despite the poor performance, it’s really not that bad with a tiny bit of patience.

The tradeoff is that you can safely transfer files without sacrificing your security.

Filed Under: Linux Tagged With: scp

  • Home
  • About
  • Search

Copyright © 2023