How to scp shadow file of b form system a?


 
Thread Tools Search this Thread
Operating Systems Solaris How to scp shadow file of b form system a?
# 1  
Old 01-25-2013
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

# 2  
Old 01-25-2013
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.
# 3  
Old 01-26-2013
RedHat

Hey ,

But give me an exaple as how to do it ?

Thanks,
Manali
# 4  
Old 01-26-2013
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.
# 5  
Old 01-27-2013
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
# 6  
Old 01-27-2013
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Shadow file help

As a part of linux hardening In shadow file all Application accounts which are not locked must contain only an asterisk “*” in the Passwd field. But how would i do it by using command? Is there any way other than modifying shadow file to accomplish this task? (3 Replies)
Discussion started by: pinga123
3 Replies

2. Shell Programming and Scripting

Shadow file

Hi, In shadow file smithj:Ep6mckrOLChF.:10063:0:99999:7::: 3rd Field 10063 indicates the number of days (since January 1, 1970) since the password was last changed. I want to get the result with script the date on which the password was last changed in YYYY-MM-DD format. can... (8 Replies)
Discussion started by: pinnacle
8 Replies

3. UNIX for Advanced & Expert Users

Using SCP command in IBM AIX to download file from remote to local system

Hi, When i run the code in solaris unix machine, the file from remote server is getting downloaded. but when i use the same code in IBM AIX remote machine, it is not running. It is saying "Erro during scp transfer." Below is the code. Please give some resolution. SCPClient client = new... (1 Reply)
Discussion started by: gravi2020
1 Replies

4. UNIX for Dummies Questions & Answers

Shadow File

I see conflicting definitions for the shadow file. For Solaris, what are the fields please? Thanks. (3 Replies)
Discussion started by: DavidS
3 Replies

5. UNIX for Advanced & Expert Users

/etc/shadow file....

Does anyone know what "!!" represents in the password field of the /etc/shadow file? :confused: (6 Replies)
Discussion started by: avcert1998
6 Replies

6. Solaris

*LK* in /etc/shadow file

my etc/shadow file showing *LK* for a particular user.. can u tell me under which circumstances a user is locked (5 Replies)
Discussion started by: vikashtulsiyan
5 Replies

7. UNIX for Advanced & Expert Users

shadow file

what does 'x' in the encrypted password field in /etc/shaodw file represent? (3 Replies)
Discussion started by: jbashir
3 Replies

8. UNIX for Dummies Questions & Answers

shadow file

Sirs, What is a shadow file,How it be usefull.For my project i have to keep the password in shawdow file also i am doing in php how can i do it. Thanks in advance, ArunKumar (3 Replies)
Discussion started by: arunkumar_mca
3 Replies

9. UNIX for Advanced & Expert Users

Changing Unix form to Microsoft Word form to be able to email it to someone.

Please someone I need information on how to change a Unix form/document into a microsoft word document in order to be emailed to another company. Please help ASAP. Thankyou :confused: (8 Replies)
Discussion started by: Cheraunm
8 Replies
Login or Register to Ask a Question