• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar

The Geek Diary

HowTos | Basics | Concepts

  • Solaris
    • Solaris 11
    • SVM
    • ZFS
    • Zones
    • LDOMs
    • Hardware
  • Linux
    • CentOS/RHEL 7
    • RHCSA notes
    • SuSE Linux Enterprise
    • Linux Services
  • VCS
    • VxVM
  • Interview Questions
  • oracle
    • ASM
    • mysql
    • RAC
    • oracle 12c
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Hadoop
    • Hortonworks HDP
      • HDPCA
    • Cloudera
      • CCA 131

Solaris : How to automate scp transfer (using passwordless ssh)

By admin

Because Secured Copy (SCP) is part of a suite of tools available with Secure Shell (SSH), you must first configure passwordless SSH before you can utilize the same for SCP. Authentication is checked against public key pairs for known hosts, instead of user id and password. Once you have SSH successfully configured to authenticate without a password, you can then utilize unprompted login with a secure copy.

Configuring passwordless scp from host A to host B

1. Host A: Generate Key-pair using the following command. Accept the default filename without entering a pass phrase. If asked for passphase press enter twice.

# ssh-keygen -t rsa

2. This above command will create two new files ( Public and Private RSA keys ) under the $HOME/.ssh/* of the user who fired the command.

id_rsa ( Private Key)
id_rsa.pub ( Public Key)

3. For ease in later identification, it is advisable to rename id_rsa.pub to a unique file name representing the system for which the key was created on because later you will copy this file to the other host you want to connect to (hostB). You will want to copy the file without overwriting the id_rsa.pub file for Host B. For Example – my hostname is hostA. So, on Host A :

# cd $HOME/.ssh
# mv id_rsa.pub id_rsa.pub-hostA

4. Copy the local public key to the remote host (HostB):

# scp $HOME/.ssh/id_rsa.pub-hostA hostB:$HOME/.ssh/id_rsa.pub-hostA

If this is your first time using ssh to connect to host B, you will receive the following message:

The authenticity of host 'hostB' can't be established.
RSA key fingerprint in md5 is: 62:84:2f:30:0b:8e:5a:28:d4:79:0f:c1:ed:c3:ab:d2
Are you sure you want to continue connecting(yes/no)?yes
Warning: Permanently added 'hostB,192.168.10.100' (RSA) to the list of known hosts.

You will need to enter the user’s password this one time only. Then, the file will be copied to host B’s .ssh directory.

5. Append your unique public key file to the public key file “authorized_keys” which creates the authorized_keys file in hostB’s .ssh directory, if it does not get created automatically with the next step. For Example, On hostB:

# touch $HOME/.ssh/authorized_keys
# cat $HOME/.ssh/id_rsa.pub-hostA >> $HOME/.ssh/authorized_keys

Host B’s .ssh directory should now look like this:

-rw-r--r-- 1 admin admin 225 Aug 3 12:51 authorized_keys
drwx------ 2 admin admin 512 Aug 3 12:51 .
-rw-r--r-- 1 admin admin 225 Aug 3 12:44 id_rsa.pub-suntime
-rw-r--r-- 1 admin admin 229 Aug 3 12:40 known_hosts
-rw------- 1 admin admin 883 Aug 3 12:39 id_rsa
-rw-r--r-- 1 admin admin 225 Aug 3 12:39 id_rsa.pub
drwxr-xr-x 114 admin admin 7680 Aug 3 12:39 ..

Verify

To verify if everything is working as expected, simply scp any file from hostA to hostB. You should not be prompted for password for the transfer.

# scp /tmp/testfile hostB:/tmp/testfile
testfile              100% |*****************************|     0       00:00

Filed Under: Solaris

Some more articles you might also be interested in …

  1. Solaris : Non-root user can’t run prtdiag command
  2. Solaris beginners guide to NFS
  3. How to setup a chroot ssh/sftp in Solaris 10
  4. Solaris 10 patching with SVM : Traditional method (non-live upgrade)
  5. The ultimate Solaris jumpstart troubleshooting guide
  6. Solaris : How to setup session idle timeout for ssh
  7. How to identify the HBA cards/ports and WWN in Solaris
  8. Solaris : How to find number of open files by a process
  9. Unix file basics : Inode, Soft Vs Hard link, Device files, Named pipes
  10. Solaris 11 (x86/64) : How to boot from DVD to single user mode

You May Also Like

Primary Sidebar

Recent Posts

  • Linux OS Service ‘cups’
  • “Warning: RPMDB altered outside of yum.” – On installing/updating/erasing a package using YUM command
  • How to Generate Unique IDs For MysQL Cluster Backups
  • Oracle 11g – New ASM features
  • ASM Fast Mirror Resync Feature – Example To Simulate Transient Disk Failure And Restore Disk
  • Archives
  • Contact Us
  • Copyright

© 2019 · The Geek Diary