![]() ![]() Copy a Single File to a Remote Server with SCPĪs an example, we will create a file on our local system and name it test-file-one. Let’s look at several SCP examples that utilize SSH keys (PEM) for authentication. path/to/remote/destination is the path to the location on the remote server where you want to copy the file. In this example, username is the user on the remote server, is the domain or IP address of the remote server, and /path/to/local/file is the path to the file on your local machine that you want to copy. For example, if your PEM file is located at /path/to/file.pem, you would use the following command to copy a file from your local machine to a remote server: scp -i /path/to/file.pem /path/to/local/file :/path/to/remote/destination To use the SCP (Secure Copy) command with a PEM file, you will need to specify the path to the PEM file using the -i option. If you logged in successfully, that means you can now proceed with the PEM file for authentication with the SCP command. The server should not prompt you to enter the server password. You should see a prompt to enter the passphrase that you set for your SSH keys. To do so, try logging in to the remote server using the PEM file for authentication. sudo chmod 400 scp_server.pemīefore starting to use SCP with the PEM file, it would be great to check if everything is okay. You should see an output similar to the image below.įinally, change the user-access permissions of the PEM file on your local machine using the command below. Type the password and hit enter to continue. You will see a prompt to enter the password of the remote password. Use the ssh-copy-id utility to copy the public key as shown below. In our case, the server uses the Username: server-one and IP-address: 192.168.1.46. Now you need to copy the public key (scp_server.pub) to the server that you want to access. Now, when you run the ls command, you should see a new file with the name scp_server.pem. ![]() Now, you need to generate a PEM file from the private key. When you run the ls command, you will see two files that were generated by the ssh-keygen utility. The ssh-keygen utility will generate the SSH keys as shown in the image below.
0 Comments
Leave a Reply. |