The FreeBSD 'zine

June 2000 : System Administration

Converting from Linux to FreeBSD
by Ryan Troy <[email protected]>

Converting Linux password files to FreeBSD and copying the users home directories.

Most people that use linux shadow there password files, this helps protect the passwords. What we need to do is uncovert the shadow and make the password file raw, to do this we:

On your Linux box we need to run the pwunconv command to convert the shadow passwords. Your pwunconv might be housed in a different directory /usr/sbin/pwunconv

This will make your passwd file raw, next we need to edit the passwd file and take out these accounts because they already exist in the FreeBSD master.passwd file (these are the accounts I took out yours maybe different).

  root:x:0:0:root:/root:/bin/bash
  bin:x:1:1:bin:/bin:
  daemon:x:0:0:daemon:/sbin:
  adm:x:3:4:adm:/var/adm:
  lp:x:4:7:lp:/var/spool/lpd:
  sync:x:5:0:sync:/sbin:/bin/sync
  shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
  halt:x:7:0:halt:/sbin:/sbin/halt
  mail:x:8:12:mail:/var/spool/mail:
  news:x:9:13:news:/var/spool/news:
  uucp:x:10:14:uucp:/var/spool/uucp:
  operator:x:11:0:operator:/root:
  games:x:12:100:games:/usr/games:
  gopher:x:13:30:gopher:/usr/lib/gopher-data:
  ftp:x:14:50:FTP User:/home/ftp:
  nobody:XkCmf9JM03dgg:99:99:Nobody:/:

Now copy your linux passwd file over to you FreeBSD box and call it linux, from the directory your are in run this make sure you put the < > around the Linux password file.

  awk -F: '{print $1":"$2":"$3":"$4"::::"$5":"$6":"$7}' < \ 
	  linux> master.passwd

This will convert your Linux password file over to FreeBSD, so lets copy the new master.passwd file to /etc:

  # cp master.passwd /etc/

Now we have to update the database so:

  # /usr/sbin/pwd_mkdb -p /etc/master.passwd

On the FreeBSD box we need to create a group for "users" because linux usually puts new users in the group "users" so we need to create the group so:

  # pw groupadd users -g 100

Next we will edit the adduser.conf file to make some changes here:

  # vi /etc/adduser.conf

Look for this line:

  # defaultgroup ('USER' for same as username or any other valid group)
  defaultgroup = USER

We need to make it (notice the changes here):

  # defaultgroup ('USER' for same as username or any other valid group)
  defaultgroup = users

This tells the system what user number to give the new users we want to set it at the last user number in the /etc/passwd file. So if your users stop at number 1901 like this:

  sgraff:*:1901:100:sgraff:/home/sgraff:/sbin/nologin

We need to set this option to:

  # new users get this uid (1000)
  uid_start = "1902"

That's it, remember FreeBSD and Linux use different directories for their shells. So its important to place the shell you have in your Linux password file in the /etc/shells file. My users shell is:

  sgraff:*:1901:100:sgraff:/home/sgraff:/sbin/nologin

So I had to add the /sbin/nologin line to the /etc/shells file.

  # $FreeBSD: src/etc/shells,v 1.2.2.1 1999/08/29 14:19:02 peter Exp $
  #
  # List of acceptable shells for chpass(1).
  # Ftpd will not allow users to connect who are not using
  # one of these shells.

  /bin/sh
  /bin/csh
  /usr/local/bin/bash
  /usr/bin/false
  /sbin/nologin
  /home/admin/shell/external/shell-wrapper

That's it, if you want to copy the users home directories over to the FreeBSD box follow these directions. Now we need to ftp the home.tgz file over to the FreeBSD box so we can use this little script to do it for you:

  #!/bin/sh -
  #
  # This simple script will .tgz your /home directory and ftp it
  # to the FreeBSD box.
  # Remember to change 1.1.1.1 to your FreeBSD box's IP address
  # And change "frank" to the username and "freebsd" to the password

  echo ""
  echo ====== `date`: ziping the home directoy /home
  cd /
  tar -zcvf home.`date +%m%d%y`.tgz home/

  echo ""
  echo ====== `date`: Uploading Tarballs

  cd /
  ftp -n -v 1.1.1.1 <<EoF
  user frank freebsd
  bin
  prompt
  mput *.tgz

Now that the home.tgz file is over to your FreeBSD box we need to place it in the / directory then we need to extract it:

  # cd /home/username        # this is the username you use to ftp
  # tar xvzf home.tgz

I successfully did this with Redhat Linux 5.1 and FreeBSD 3.3-STABLE and 3.4-STABLE.

Current Issue
. Issue #06 : July 2000

Old Issues
. Issue #01 : February 2000
. Issue #02 : March 2000
. Issue #03 : April 2000
. Issue #04 : May 2000
. Issue #05 : June 2000

Quick Links
. Table of Contents
. Mailing Lists
. FreeBSD Events
. User Group Calendar
. Site Statistics
. Old Articles
. Latest News
. Press Releases
. Contribute
. Send us Feedback
. Other Resources
. Submit an Article
. Submit an Event

Today's Fortune
New York's got the ways and means; Just won't let you be. -- The Grateful Dead

FreeBSD 'zine Poll
Are you going to BSDCon?
Yes.
No.
Maybe.
What the hell is BSDCon?
Results More polls

Sponsors
. VicFUG

Download
. Issue #01 : Download
. Issue #02 : Download
. Issue #03 : Download
. Issue #04 : Download
. Issue #05 : Download
. Issue #06 : Download

Search

Runs on FreeBSD

Add Channel to My Netscape

DaemonNews

Contact: <[email protected]>
This site and the tarballs are built every 6 hours.
Copyright � 1998-2000, The FreeBSD 'zine
Code revision: 07/24/2000��All rights reserved.