• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Run SCP Without Password Prompt Interruption in Linux

by admin

Question: How to run scp command without prompting for any password in Linux?

The password-less operation can be added to cron or schedule in case of reducing manual intervention. The various methods of copy operations include rsync, bacula, and keygen with scp.

1. Generate a key using ssh-keygen for any particular user and server. For example, you can follow this:

# ssh-keygen -t rsa -b 4096 -C "root@localhost"
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
33:4c:b1:a1:b0:f7:3a:85:0c:85:b9:6b:eb:c6:69:8b root@localhost
The key's randomart image is:
+--[ RSA 4096]----+
| .o. o |
| o+ . + |
| o.o o |
| .+ = |
| .o S |
| o o o |
| o oo |
| .* . |
| E+o. |
+-----------------+

We can see the generated key as shown below with .pub extention:

# ls -l .ssh/
total 8
-rw-------. 1 root root 3239 Aug 13 13:11 id_rsa
-rw-r--r--. 1 root root 736 Aug 13 13:11 id_rsa.pub

2. Once the the public key is generated, copy the .pub file as authorized_keys under .ssh directory under user home for the user in destination server. Once done, try to do ssh which will connect without password.

# cat .ssh/id_rsa.pub | ssh root@server2 'cat >> .ssh/authorized_keys'
# ssh root@server2

Now you can copy a file using scp as shown below:

# scp test_file.txt root@server2:/tmp/
test_file.txt 100% 20 0.0KB/s 00:00

Filed Under: Linux

Some more articles you might also be interested in …

  1. deno: A secure runtime for JavaScript and TypeScript
  2. ksh Command Examples
  3. “glab auth” Command Examples
  4. flatpak: command not found
  5. gcalcli: Command-line tool to interact with Google Calendar
  6. dolt merge: Join two or more development histories together
  7. physlock: command not found
  8. nmcli: command not found
  9. grip Command Examples
  10. what does .tar file mean

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright