Logging In to a Remote Computer in Ubuntu

|

The most basic type of ssh connection is a remote login. This will give you a command prompt on the remote computer, as if you had just sat down in front of it and opened GNOME Terminal. But before you can log in to any machine via ssh, you’ll need to be sure the remote computer is able to accept ssh connections. This means that it needs to be running the ssh server program (referred to as a service), and also that its firewall has an open port for incoming connections.

The two major components of OpenSSH are the client and server. Most distributions install both items and run the server component all the time. However, only the client component of SSH is installed under Ubuntu. To install the server component, and therefore access your Ubuntu system remotely, you’ll need to open Synaptic Package Manager (System -> Administration) and search for openssh-server. Click to install it. Configuration will be automatic, although if you’re using the Ubuntu firewall, you will need to configure an incoming rule to open port 22.

Initiating an ssh remote shell session with a remote machine is usually achieved by typing something similar to the following at a command prompt on the local machine:

ssh @

In other words, you specify the username you want to log in as, as well as the IP address of the machine. If there’s a fully qualified domain name (FQDN) for the system you want to access, you could specify that instead of the IP address.

You’ll be prompted for your password which, obviously, is the password for the account you’re trying to log in to on the remote computer.

After confirming that you want to make the connection, you’ll be invited to enter the password for the user account under which you initiated the ssh connection. Once this is done, you should find yourself with a shell login on the remote computer. You can run the same commands as usual and perform identical tasks.

The machine you’re logged in to will show no symptoms of being used remotely. This isn’t like the movies, where what you type on your local machine is somehow mirrored on the remote machine for all to see. However, obviously, if a user of the remote machine were to view her network connections using something similar to the netstat command, then she would see another computer attached via ssh. To end an ssh session, simply type exit. This will then return you to the command prompt on your own machine.


Managing Remote Sessions
Whenever you open any kind of shell to enter commands and run programs, you might have noticed that any commands you start running last only as long as the shell window is open. When the shell window is closed, any task running within it ends, too. This is because the shell is seen as the “owner” of the process, and when the owner dies, any processes it started also die. When using ssh to start a remote shell session, this also applies. Whenever you log out, any tasks you were running are ended. This can be annoying if, for example, you’ve started a lengthy download on the remote machine. Effectively, you must remain logged in via ssh until the download has finished. To get around this, you can use the handy screen program. This isn’t specifically designed to be an aid to remote logins, but there’s no reason why it cannot be used in such a situation. The screen program effectively starts shell sessions that stick around, even if the shell window is closed or the ssh connection is ended or lost. After logging in to the remote computer via ssh, you can start a screen session by simply typing the program name at the prompt:

screen

After pressing the spacebar as prompted to start the program, there won’t be any indication that you’re running a screen session. There’s no taskbar at the bottom of the terminal window, for example. Screen works completely in the background. Let’s consider what happens when you detach and then reattach to a screen session. To detach from the screen session, press Ctrl+A and then Ctrl+D. You’ll then be returned to the standard shell and, in fact, you could now disconnect from your ssh session as usual. However, the screen session will still be running in the background on the remote computer. To prove this, you could log back in, and then type this:

screen -r

This will resume your screen session, and you should be able to pick up quite literally where you left off; any output from previous commands will be displayed. To quit a screen session, you can either type exit from within it or press Ctrl+A, and then Ctrl+\ (backslash). The screen program is very powerful. To learn more about it, read its man page. To see a list of its keyboard commands, press Ctrl+A, and then type a question mark (?) while screen is running.

Source of Information : Beginning Ubuntu Linux - From Novice To Professional

0 comments:

Subscribe to Computing Tech

Enter your email address:

Delivered by FeedBurner

Add to Technorati Favorites Top Blogs