NOTE

See Chapter 14, 'Networking,' to see how to set up network interfaces with Linux to support remote network logins and Chapter 11 to see how to start remote access services (such as sshd).

The best and most secure way (barring future exploits) to log in to a remote Linux computer is to use the ssh or Secure Shell client. Your login and session are encrypted while you work on the remote computer. The ssh client features many different command-line options, but can be simply used with the name or IP address of the remote computer, like this:

[andrew@teletran ~]$ ssh 192.168.0.10

The authenticity of host '192.168.0.10 (192.168.0.10)' can't be established.

RSA key fingerprint is 32:90:31:1e:31:1c:a8:d4:9a:0b:07:78:93:9d:65:df.

Are you sure you want to continue connecting (yes/no)? yes

The first time you connect with a remote computer using ssh, Linux displays the remote computer's encrypted identity key and asks you to verify the connection. After you type yes and press Enter, you are warned that the remote computer's identity (key) has been entered in a file named known_hosts under the .ssh directory in your home directory. You are also prompted to enter your password:

Warning: Permanently added '192.168.0.10' (RSA)

to the list of known hosts.

[email protected]'s password:

andrew@fedora:~$

After entering your password, you can then work on the remote computer. Again, every thing you enter on the keyboard in communication with the remote computer is encrypted. Use the exit or logout commands to exit your session and return to the shell on your computer.

Using Environment Variables

A number of in-memory variables are assigned and loaded by default when the user logs in. These variables are known as shell environment variables, which can be used by various commands to get information about your environment, such as the type of system you are running, your home directory, and the shell in use. Environment variables are used by Linux operating systems to help tailor the computing environment of your system, and include helpful specifications and setup, such as default locations of executable files and software libraries. If you begin writing shell scripts, you might use environment variables in your scripts. Until then, you only need to be aware of what environment variables are and do.

The following list includes a number of environment variables, along with descriptions of how the shell uses them:

PWD — To provide the name of the current working directory, used by the pwd command (such as /home/andrew/foo)

USER — To declare the user's name, such as andrew

LANG — To set language defaults, such as English

SHELL — To declare the name and location of the current shell, such as /bin/bash

PATH — To set the default location of executable files, such as /bin, /usr/bin, and so on

LD_LIBRARY_PATH — To declare the location of important software libraries (because most, but not all, Linux commands use shared resources)

TERM — To set the type of terminal in use, such as vt100, which can be important when using screen-oriented programs, such as text editors

MACHINE — To declare system type, system architecture, and so on

NOTE

Each shell can have its own feature set and language syntax, as well as a unique set of default environment variables. See Chapter 15, 'Remote Access with SSH,' for more information about using the different shells included with Fedora.

At the command line, you can use the env or printenv commands to display these environment variables, like so:

$ env

SSH_AGENT_PID=2881

HOSTNAME=teletran.hudson.com

SHELL=/bin/bash

TERM=xterm

DESKTOP_STARTUP_ID=

USERNAME=andrew

MAIL=/var/spool/mail/andrew

PATH=/usr/kerberos/bin:/usr/lib/ccache:/usr/local/bin:

/usr/bin:/bin:/home/andrew/bin

DESKTOP_SESSION=default

INPUTRC=/etc/inputrc

PWD=/home/andrew

KDEDIRS=/usr

SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass

SHLVL=2

HOME=/home/andrew

DISPLAY=:0.0

This abbreviated list shows a few common variables. These variables are set by configuration or resource files contained in the /etc, /etc/skel, or user /home directory. You can find default settings for bash, for example, in /etc/profile, /etc/bashrc, .bashrc, or .bash_profile files installed in your home directory. Read the man page for bash for details about using these configuration files.

One of the most important environment variables is $PATH, which defines the location of executable files. For example, if, as a regular user, you try to use a command that is not located in your $PATH (such as the ifconfig command), you will see something like this:

$ ifconfig

-bash: ifconfig: command not found

However, you might know that ifconfig is definitely installed on your system, and you can verify this by using the whereis command, like so:

$ whereis ifconfig

ifconfig: /sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz

You can also run the command by typing its full pathname, or complete directory specification like

Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату