How to scp shadow file of b form system a? | Unix Linux Forums | Solaris

  Go Back    


Solaris The Solaris Operating System, usually known simply as Solaris, is a Unix-based operating system introduced by Sun Microsystems. The Solaris OS is now owned by Oracle.

How to scp shadow file of b form system a?

Solaris


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-25-2013
manalisharmabe manalisharmabe is offline
Registered User
 
Join Date: Jul 2011
Last Activity: 18 April 2014, 7:22 AM EDT
Posts: 154
Thanks: 96
Thanked 2 Times in 2 Posts
CPU & Memory How to scp shadow file of b form system a?

Hi all,

What I have already done:
1. Same user created on both system and passwordless ssh form system a to system b through that user

I need to write a small script to copy /etc/shadow file of sytem a to system b,
script needs to be executed on system b.
But as /etc/shadow file is owned by root ,it shows message like permission denied.

inshort i want to execute
Code:
scp 192.168.1.21:/etc/shadow localmachine

Sponsored Links
    #2  
Old 01-25-2013
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 17 April 2014, 6:29 PM EDT
Location: Saskatchewan
Posts: 18,531
Thanks: 681
Thanked 3,036 Times in 2,856 Posts
You'll have to log in as root, or somehow contrive to get root access after logging in.

Even the slightest insecurity in the system you use could have dire consequences.
Sponsored Links
    #3  
Old 01-26-2013
manalisharmabe manalisharmabe is offline
Registered User
 
Join Date: Jul 2011
Last Activity: 18 April 2014, 7:22 AM EDT
Posts: 154
Thanks: 96
Thanked 2 Times in 2 Posts
RedHat

Hey ,

But give me an exaple as how to do it ?

Thanks,
Manali
    #4  
Old 01-26-2013
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 18 April 2014, 11:10 PM EDT
Location: NM
Posts: 10,058
Thanks: 250
Thanked 756 Times in 711 Posts
on Server A
as root user

Code:
chmod 444 /etc/shadow

on server B
as root user

Code:
chmod 644 /etc/shadow
cp /etc/shadow /etc/shadow.keep   # this is to revert if it screws up
scp me@serverA::/etc/shadow .
chmod 400 /etc/shadow

TEST several user logins on serverB. Note: Create separate processes for login testing, KEEP YOUR root PROCESS active no matter what, so if you broke stuff, you can still fix it. If you really broke things, nobody can login to serverB, including root. Use the copy /etc/shadow.keep to restore.

Go back to serverA

Code:
chmod 400 /etc/shadow

This effort will not work to duplicate passwords if you are using NIS or LDAP or you have messed with PAM setup on either box.
Sponsored Links
    #5  
Old 01-27-2013
manalisharmabe manalisharmabe is offline
Registered User
 
Join Date: Jul 2011
Last Activity: 18 April 2014, 7:22 AM EDT
Posts: 154
Thanks: 96
Thanked 2 Times in 2 Posts
HI ,
Thanks for your replies.

But my requirement is this. below is my script and I need to SCP /etc/shadow from remote server to my DR system.

Now please guide as how to accomplish thisbecause it ask for root password before copying,
NOte I have setpasswordless login from same user on all the systems.

#!/bin/bash

MACHINE=mainserver
for server in "system1" "system2" "system3" "system4" "system5"
SSH_SERVER=`ssh $server exec uname -n`
echo "Copying file from $SSH_SERVER......."
if [ $SSH_SERVER = $MACHINE ]; then
scp -q $SSH_SERVER:/etc/passwd /DR/$SSH_SERVER
scp -q $SSH_SERVER:/etc/group /DR/$SSH_SERVER
scp -q $SSH_SERVER:/etc/services /DR/$SSH_SERVER /etc/profile
scp -q $SSH_SERVER:/etc/printers.conf /DRs/$SSH_SERVER
scp -q $SSH_SERVER:/etc/profile /DR/$SSH_SERVER
scp -q $SSH_SERVER:/etc/dfs/dfstab /DR/$SSH_SERVER
scp -q $SSH_SERVER:/etc/dfs/sharetab /DR/$SSH_SERVER
scp -q $SSH_SERVER:/etc/vfstab /DR/$SSH_SERVER
scp -q $SSH_SERVER:/etc/shells /DR/$SSH_SERVER

else
scp -q $SSH_SERVER:/etc/passwd /DR/$SSH_SERVER
scp -q $SSH_SERVER:/etc/group /DR/$SSH_SERVER
scp -q $SSH_SERVER:/etc/services /DR/$SSH_SERVER
scp -q $SSH_SERVER:/etc/printers.conf /DR/$SSH_SERVER
scp -q $SSH_SERVER:/etc/profile /DR/$SSH_SERVER
scp -q $SSH_SERVER:/etc/vfstab /DR/$SSH_SERVER
scp -q $SSH_SERVER:/etc/shells /DR/$SSH_SERVER
fi
done
Sponsored Links
    #6  
Old 01-27-2013
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
who?
 
Join Date: Dec 2003
Last Activity: 18 April 2014, 4:35 PM EDT
Location: /dev/ph
Posts: 4,712
Thanks: 54
Thanked 411 Times in 382 Posts
You cannot copy /etc/shadow in the same way as you are scp'ing /etc/passwd and the other files you list. You need root permission to make this happen because of the mode (permissions) of /etc/shadow. Just doing a passwordless scp is not going to fix this issue for you.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Using SCP command in IBM AIX to download file from remote to local system gravi2020 UNIX for Advanced & Expert Users 1 01-30-2009 06:39 AM
/etc/shadow file.... avcert1998 UNIX for Advanced & Expert Users 6 01-18-2008 02:40 PM
shadow file arunkumar_mca UNIX for Dummies Questions & Answers 3 12-31-2004 10:55 PM
Changing Unix form to Microsoft Word form to be able to email it to someone. Cheraunm UNIX for Advanced & Expert Users 8 05-24-2002 03:58 AM



All times are GMT -4. The time now is 05:24 AM.