Friday, November 20, 2009

How do I configure minicom to communicate with a modem or serial device?

How do I configure minicom to communicate with a modem or serial device?



Release Found: Red Hat Enterprise Linux

Symptom:
Minicom is not able to communicate with a serial port device, such as a modem.

Solution:

The minicom program is a terminal emulation program included with Red Hat Enterprise Linux. It is a tool accessed from the command line. Minicom provides a terminal emulation interface for a serial device or a modem. It also has a text-based menu to access various features.

You will need to have the minicom package installed to use it. If regular users need to have access to minicom, then you will need to grant permission on the relevant device files. We have related articles to help.

In addition you will also need to know the capabilities of the device you are connecting to. For a modem it is usually safe to use a speed of 57,600 baud (number of 8-bit characters per second). Other serial devices may communicate at a different rates. Please note, that this rate is the speed between your computer and the device. In the case of the modem to modem signaling rate this speed may be different depending on the device.

Most present day serial devices support 8 data bits, No parity, and 1 stop bit. If the these settings are different for your device then make a note of it.

You will get the fastest and most reliable connection with a device that supports Hardware (i.e. CTS/RTS) flow control. This option is often used with modems and generally is well supported. Other serial devices may or may not specify flow control capabilities. If the flow control setting is not specified in the specifications for the device, you are usually safe using no flow control.

To set the system-wide parameters in minicom you will need to execute minicom as root with the -s (setup) option. For example:

 
# minicom -s
 
            ┌─────[configuration]──────┐
            │ Filenames and paths      │
            │ File transfer protocols  │
            │ Serial port setup        │
            │ Modem and dialing        │
            │ Screen and keyboard      │
            │ Save setup as dfl        │
            │ Save setup as..          │
            │ Exit                     │
            │ Exit from Minicom        │
            └──────────────────────────┘ 
    



Generally, in Red Hat Linux, the serial devices are typically represented as follows:

/dev/ttyS0 -> First serial port (i.e. COM 1)
/dev/ttyS1 -> Second serial port (i.e. COM 2)
/dev/ttyS2 -> Third serial port (i.e. COM 3)
/dev/ttyS3 -> Fourth serial port (i.e. COM 4) (Note: that the device name uses a capatal "S" before the number) --or-- /dev/cua0 -> First serial port (i.e. COM 1)
/dev/cua1 -> Second serial port (i.e. COM 2)
/dev/cua2 -> Third serial port (i.e. COM 3)
/dev/cua3 -> Fourth serial port (i.e. COM 4) General Explination:The difference between the ttyS and cua devices is technical. Generally speaking if one doesn't work try the other. If both don't work then you have some other problem. Technical Explination: When connecting to the ttyS devices, they will "block" until the carrier detect line (DCD) goes high. The cua devices are "non-blocking" and will accept the connection even if there is no DCD signal.

Use the arrow keys to navigate the menu selecting the option "Serial port setup" first. Press [Enter] to select this option and another window will open (see below). The letters on the left side of the window are used to select which setting to modify. Most likely you will want to modify "A - Serial Device" to use one of the device files listed above. Press [Enter] once you are done typing the device name.

Next, choose option "E - Bps/Par/Bits". Another window will open displaying the possible communication parameters. Choose the baud rate (speed) on the left by pressing the corresponding letter (A - J). The 8N1 at the top of the window refers to the options 8 data bits, No parity, and 1 stop bit. If you need to change these settings, then press the corresponding letter for the new setting. When you are done, press [Enter] to exit the menu.

                                                            
    ┌───────────────────────────────────────────────────────────────────────┐
    │ A -    Serial Device      : /dev/cua0                                 │
    │ B - Lockfile Location     : /var/lock                                 │
    │ C -   Callin Program      :                                           │
    │ D -  Callout Program      :                                           │
    │ E -    Bps/Par/Bits       : 57600 8N1                                 │
    │ F - Hardware Flow Control : Yes                                       │
    │ G - Software Flow Control : No                                        │
    │                                                                       │
    │    Change which setting?                                              │
    └───────────────────────────────────────────────────────────────────────┘
            │ Screen and keyboard      │
            │ Save setup as dfl        │
            │ Save setup as..          │
            │ Exit                     │
            │ Exit from Minicom        │
            └──────────────────────────┘             
    



If required, you can change the flow control setting with option F and G. I would not recommend turning on both hardware and software at the same time. Software flow control is rarely used, Hardware is more common as is no flow control. Again, pressing [Enter] will exit this menu and take you back to the main configuration menu.

Next, arrow down to "Modem and dialing" and press [Enter]. You will get a screen full of options resembling the following:

 
 ┌────────────────────[Modem and dialing parameter setup]─────────────────────┐
 │                                                                            │
 │ A - Init string ......... ~~AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0               │
 │ B - Reset string ........ ~ATZ~                                            │
 │ C - Dialing prefix #1.... ATDT                                             │
 │ D - Dialing suffix #1....                                                  │
 │ E - Dialing prefix #2.... ATDP                                             │
 │ F - Dialing suffix #2....                                                  │
 │ G - Dialing prefix #3.... ATX1DT                                           │
 │ H - Dialing suffix #3.... ;X4D                                             │
 │ I - Connect string ...... CONNECT                                          │
 │ J - No connect strings .. NO CARRIER            BUSY                       │
 │                           NO DIALTONE           VOICE                      │
 │ K - Hang-up string ...... ~~+++~~ATH                                       │
 │ L - Dial cancel string ..                                                  │
 │                                                                            │
 │ M - Dial time ........... 45      Q - Auto bps detect ..... No             │
 │ N - Delay before redial . 2       R - Modem has DCD line .. Yes            │
 │ O - Number of tries ..... 10      S - Status line shows ... DTE speed      │
 │ P - DTR drop time (0=no). 1       T - Multi-line untag .... No             │
 │                                                                            │
 │ Change which setting?       (Return or Esc to exit)                        │
 └────────────────────────────────────────────────────────────────────────────┘



If you are using a modem, you may need to modify option A. See your hardware documentation for details. Generally the other default options are suitable for most modems.

If you are not configuring for a modem, I would recommend blanking out the strings for options A, B, and K.

The other options at the bottom can be set if required but the defaults are usually okay. Press [enter] to exit this screen.

You may find, while connected to your device that the [Backspace] key does not behave properly. If so, you will want to return to this menu and change the setting under Screen and keyboard

Lastly, choose "Save setup as defl" to save your default configuration. The "Configuration Saved" message should close on it's own in a few seconds. Choose Exit and your ready to test your setup.

If you ever need to return to this configuration menu from the terminal screen, press Ctrl+A, release, then press the letters "z" then "o".

For additional features and information on minicom you will find documentation for located under /usr/share/doc/minicom-/doc/


Configuring a Samba Server

Configuring a Samba Server

The default configuration file (/etc/samba/smb.conf) allows users to view their Red Hat Linux home directories as a Samba share. It also shares any printers configured for the Red Hat Linux system as Samba shared printers. In other words, you can attach a printer to your Red Hat Linux system and print to it from the Windows machines on your network.

17.2.1. Graphical Configuration

To configure Samba using a graphical interface, use the Samba Server Configuration Tool. For command line configuration, skip to Section 17.2.2 Command Line Configuration.

The Samba Server Configuration Tool is a graphical interface for managing Samba shares, users, and basic server settings. It modifies the configuration files in the /etc/samba/ directory. Any changes to these files not made using the application are preserved.

To use this application, you must be running the X Window System, have root privileges, and have the redhat-config-samba RPM package installed. To start the Samba Server Configuration Tool from the desktop, go to the Main Menu Button (on the Panel) => System Settings => Server Settings => Samba Server or type the command redhat-config-samba at a shell prompt (for example, in an XTerm or a GNOME terminal).


Figure 17-1. Samba Server Configuration Tool

Note

The Samba Server Configuration Tool does not display shared printers or the default stanza that allows users to view their own home directories on the Samba server.


17.2.1.1. Configuring Server Settings

The first step in configuring a Samba server is to configure the basic settings for the server and a few security options. After starting the application, select Preferences => Server Settings from the pulldown menu. The Basic tab is displayed as shown in Figure 17-2.




Figure 17-2. Configuring Basic Server Settings


On the Basic tab, specify which workgroup the computer should be in as well as a brief description of the computer. They correspond to the workgroup and server string options in smb.conf.


Figure 17-3. Configuring Security Server Settings


The Security tab contains the following options:

· Authentication Mode — This corresponds to the security option. Select one of the following types of authentication.

o Domain — The Samba server relies on a Windows NT Primary or Backup Domain Controller to verify the user. The server passes the username and password to the Controller and waits for it to return. Specify the NetBIOS name of the Primary or Backup Domain Controller in the Authentication Server field.

The Encrypted Passwords option must be set to Yes if this is selected.

o Server — The Samba server tries to verify the username and password combination by passing them to another Samba server. If it can not, the server tries to verify using the user authentication mode. Specify the NetBIOS name of the other Samba server in the Authentication Server field.

o Share — Samba users do not have to enter a username and password combination on a per Samba server basis. They are not prompted for a username and password until they try to connect to a specific shared directory from a Samba server.

o User — (Default) Samba users must provide a valid username and password on a per Samba server basis. Select this option if you want the Windows Username option to work. Refer to Section 17.2.1.2 Managing Samba Users for details.

· Encrypt Passwords — (Default value is Yes) This option must be enabled if the clients are connecting from a Windows 98, Windows NT 4.0 with Service Pack 3, or other more recent versions of Microsoft Windows. The passwords are transfered between the server and the client in an encrypted format instead of in as a plain-text word that can be intercepted. This corresponds to the encrypted passwords option. Refer to Section 17.2.3 Encrypted Passwords for more information about encrypted Samba passwords.

· Guest Account — When users or guest users log into a Samba server, they must be mapped to a valid user on the server. Select one of the existing usernames on the system to be the guest Samba account. When guests logs in to the Samba server, they have the same privileges as this user. This corresponds to the guest account option.

After clicking OK, the changes are written to the configuration file and the daemon is restart; thus, the changes take effect immediately.

17.2.1.2. Managing Samba Users

The Samba Server Configuration Tool requires that an existing user account be active on the Red Hat Linux system acting as the Samba server before a Samba user can be added. The Samba user is associated with the existing Red Hat Linux user account.

Figure 17-4. Managing Samba Users

To add a Samba user, select Preferences => Samba Users from the pulldown menu, and click the Add User button. On the Create New Samba User window select a Unix Username from the list of existing users on the local system.

If the user has a different username on a Windows machine and will be logging into the Samba server from the Windows machine, specify that Windows username in the Windows Username field. The Authentication Mode on the Security tab of the Server Settings preferences must be set to User for this option to work.

Also configure a Samba Password for the Samba User and confirm the Samba Password by typing it again. Even if you select to use encrypted passwords for Samba, it is recommended that the Samba passwords for all users are different from their Red Hat Linux system passwords.

To edit an existing user, select the user from the list, and click Edit User. To delete an existing Samba user, select the user, and click the Delete User button. Deleting a Samba user does not delete the associated Red Hat Linux user account.

The users are modified immediately after clicking the OK button.


17.2.1.3. Adding a Share



Figure 17-5. Adding a Share

To add a share, click the Add button. The Basic tab configures the following options:

· Directory — The directory to share via Samba. The directory must exist.

· Descriptions — A brief description of the share.

· Basic Permissions — Whether users should only be able to read the files in the shared directory or whether they should be able to read and write to the shared directory.

On the Access tab, select whether to allow only specified users to access the share or whether to allow all Samba users to access the share. If you select to allow access to specific users, select the users from the list of available Samba users.

The share is added immediately after clicking OK.

17.2.2. Command Line Configuration

Samba uses /etc/samba/smb.conf as its configuration file. If you change this configuration file, the changes do not take effect until you restart the Samba daemon with the command service smb restart.

To specify the Windows workgroup and a brief description of the Samba server, edit the following lines in your smb.conf file:

workgroup = WORKGROUPNAME

server string = BRIEF COMMENT ABOUT SERVER

Replace WORKGROUPNAME with the name of the Windows workgroup to which this machine should belong. The BRIEF COMMENT ABOUT SERVER is optional and is used as the Windows comment about the Samba system.

To create a Samba share directory on your Linux system, add the following section to your smb.conf file (after modifying it to reflect your needs and your system):

[sharename]

comment = Insert a comment here

path = /home/share/

valid users = tfox carole

public = no

writable = yes

printable = no

create mask = 0765

The above example allows the users tfox and carole to read and write to the directory /home/share, on the Samba server, from a Samba client.

17.2.3. Encrypted Passwords

In Red Hat Linux 9 encrypted passwords are enabled by default because it is more secure. If encrypted passwords are not used, plain text passwords are used, which can be intercepted by someone using a network packet sniffer. It is recommended that encrypted passwords be used.

The Microsoft SMB Protocol originally used plaintext passwords. However, Windows NT 4.0 with Service Pack 3 or higher, Windows 98, Windows 2000, Windows ME, and Windows XP require encrypted Samba passwords. To use Samba between a Red Hat Linux system and a system running one of these Windows operating systems, you can either edit your Windows registry to use plaintext passwords or configure Samba on your Linux system to use encrypted passwords. If you choose to modify your registry, you must do so for all your Windows machines — this is risky and may cause further conflicts. It is recommended that you use encrypted passwords for better security.

To configure Samba on your Red Hat Linux system to use encrypted passwords, follow these steps:

1. Create a separate password file for Samba. To create one based on your existing /etc/passwd file, at a shell prompt, type the following command:

cat /etc/passwd | mksmbpasswd.sh > /etc/samba/smbpasswd

2. If the system uses NIS, type the following command:

ypcat passwd | mksmbpasswd.sh > /etc/samba/smbpasswd

3. The mksmbpasswd.sh script is installed in your /usr/bin directory with the samba package.

4. Change the permissions of the Samba password file so that only root has read and write permissions:

chmod 600 /etc/samba/smbpasswd

5. The script does not copy user passwords to the new file, and a Samba user account is not active until a password is set for it. For higher security, it is recommended that the user's Samba password be different from the user's Red Hat Linux password. To set each Samba user's password, use the following command (replace username with each user's username):

smbpasswd username

6. Encrypted passwords must be enabled in the Samba configuration file. In the file smb.conf, verify that the following lines are not commented out:

encrypt passwords = yes

smb passwd file = /etc/samba/smbpasswd

7. Make sure the smb service is started by typing the command service smb restart at a shell prompt.

8. If you want the smb service to start automatically, use ntsysv, chkconfig, or Services Configuration Tool to enable it at runtime. Refer to Chapter 14 Controlling Access to Services for details.

Tip

Tip


Read /usr/share/doc/samba-<version>/docs/htmldocs/ENCRYPTION.html to learn more about encrypted passwords. (replace <version> with the version number of Samba that you have installed).

The pam_smbpass PAM module can be used to sync users' Samba passwords with their system passwords when the passwd command is used. If a user invokes the passwd command, the password he uses to log in to the Red Hat Linux system as well as the password he must provide to connect to a Samba share are changed.

To enable this feature, add the following line to /etc/pam.d/system-auth below the pam_cracklib.so invocation:

password required /lib/security/pam_smbpass.so nullok use_authtok try_first_pass

17.2.4. Starting and Stopping the Server

On the server that is sharing directories via Samba, the smb service must be running.

View the status of the Samba daemon with the following command:

/sbin/service smb status

Start the daemon with the following command:

/sbin/service smb start

Stop the daemon with the following command:

/sbin/service smb stop

To start the smb service at boot time, use the command:

/sbin/chkconfig --level 345 smb on

You can also use chkconfig, ntsysv or the Services Configuration Tool to configure which services start at boot time. Refer to Chapter 14 Controlling Access to Services for details.

Connecting to a Samba Share

To connect to a Linux Samba share from a Microsoft Windows machine, use Network Neighborhood or the graphical file manager.

To connect to a Samba share from a Linux system, from a shell prompt, type the following command:

smbclient //hostname/sharename -U username

Replace hostname with the hostname or IP address of the Samba server you want to connect to, sharename with the name of the shared directory you want to browse, and username with the Samba username for the system. Enter the correct password or press [Enter] if no password is required for the user.

If you see the smb:\> prompt, you have successfully logged in. Once you are logged in, type help for a list of commands. If you wish to browse the contents of your home directory, replace sharename with your username. If the -U switch is not used, the username of the current user is passed to the Samba server.

To exit smbclient, type exit at the smb:\> prompt.

You can also use Nautilus to view available Samba shares on your network. Select Main Menu Button (on the Panel) => Network Servers to view a list of Samba workgroups on your network. You can also type smb: in the Location: bar of Nautilus to view the workgroups.

As shown in Figure 17-6, an icon appears for each available SMB workgroup on the network.


Figure 17-6. SMB Workgroups in Nautilus

Double-click one of the workgroup icons to view a list of computers within the workgroup


Figure 17-7. SMB Machines in Nautilus

As you can see from Figure 17-7, there is an icon for each machine within the workgroup. Double-click on an icon to view the Samba shares on the machine. If a username and password combination is required, you are prompted for them.

Alternately, you can also specify a username and password combination in the Location: bar using the following syntax (replace user, password, servername, and sharename with the appropriate values):

smb://user:password@servername/sharename/