Working on a remote computer

General Information

In many cases we find it useful to connect to remote machines and work there, or there is a need to transfer files between different computers. In the early days of Unix these tasks were accomplished with rlogin (remote login), rsh (remote shell), rcp (remote copy), and ftp (file transfer protocol). However, we don't live in an innocent world, and soon a necessity arose for secure transactions. Hence, the above programs are typically replaced nowadays with slogin (secure login), ssh (secure shell), scp (secure copy), and sftp (secure ftp) respectively which rely on cryptographic algorithms that ensure security. A brief introduction to these methods is described in this webpage. Moreover, graphical user interface frontends have been developed for almost any platform; links and references are given.

Contents

[Top] [Terminal HOW-TO]


Command line

Here are the basic command line tools so that someone can establish a secure remote connection as well as transfer files between computers in a secure way: [Contents]

Secure login (slogin)

The command slogin can be used so that someone can connect to a remote host (in a secure way) and work on a terminal. All you need to know is your username, your password, and the name (or ip address) of the remote host (of course the remote host has to support the option that you can login from another computer, but this is assumed for everything that is presented in this webpage). Hence, if your username is user and you want to connect to icarus.uic.edu you can do so with the following command:
$ slogin user@icarus.uic.edu
Password: 
Last login: Sun Jan 27 18:21:42 2008 from xxx-xxx-xxx-xxx.

[06:21pm] icarus:~$ 
i.e. your username followed by @ and followed by the remote machine name (or ip).
At this point you can work on the terminal infront of you, but all the commands are executed at icarus.uic.edu and the output of these commands is presented in your screens. Use the rest of the tutorial to exploit the power that you have under Unix. Don't forget to terminate your session with exit or simply ^D.
[Command line] [Contents]

Secure shell (ssh)

Every now and then a necessity arises to execute just a single command on a remote computer. This can be done with the ssh command. The syntax is simple and similar to slogin but now the command that you want to execute remotely must also be stated after the user@machine part. Assume for example that you want to ask icarus.uic.edu about the current time in Chicago. All you need to do is give the following command:
$ ssh user@icarus.uic.edu date
Password: 
Sun Jan 27 18:44:01 CST 2008
$ 
or even compute the time difference between orion.di.uoa.gr which is located in Athens, Greece, and icarus.uic.edu which is located in Chicago:
[06:47pm] icarus:~$ ssh user@orion.di.uoa.gr date; date
Password: 
Mon Jan 28 02:47:31 EET 2008
Sun Jan 27 18:47:31 CST 2008
[06:47pm] icarus:~$ 
Note that the first command is executed remotely, while the latter one is executed locally at icarus.

ssh as slogin

An important option of ssh is that one can call it without specifying a given command to be executed on the remote host. In this case ssh behaves like slogin and one can open a session on the remote machine.
$ ssh user@icarus.uic.edu
Password:
Last login: Sun Jan 27 19:15:12 2008 from xxx-xxx-xxx-xxx.

[07:15pm] icarus:~$ 
I guess this property as well as the fact that ssh has fewer characters from slogin (and hence it is faster to type it) is the reason that slogin is not implemented actually in practice; i.e. whenever you call slogin you actually call ssh. At the moment you can verify that with the following strange command:
$ slogin user@icarus.uic.edu date
Did you manage to login?

Using a different port

On some machines as an extra precautionary measure ssh is supported on a different port from the default one (22). You can specify the desired port with the option -p followed by the number of the port. For example, if you want to connect at icarus, you can do so with the command:
$ ssh -p 22 user@icarus.uic.edu
[Command line] [Contents]

Secure ftp (sftp)

sftp is the secure way of running ftp; i.e. is the secure way to transfer many files between two computers. You can activate a secure ftp session with the command:
$ sftp user@icarus.uic.edu
Connecting to icarus.uic.edu...
Password: 
sftp> 
You can terminate a session at any time by giving bye or exit at the prompt:
sftp> bye
$ 
The interface is very intuitive. You can upload (put) to the remote host a file named local_file with a command of the form:
sftp> put local_file
Similarly you can download (get) the remote_file with a command of the form:
sftp> get remote_file
Commands pwd, cd, and ls are executed on the remote host, while lpwd, lcd, and lls are their equivalent commands at the local host (hence the l that precedes the names of the commands).
[Command line] [Contents]

Secure copy (scp)

scp is typically used to copy one file between two computers. The idea is that a session between the two computers is active as long as there is a transmission of one (or more) files between the two computers (contrary to sftp where you can have idle time while the session is active). Note that you have to specify the path where the file is going to be saved at the remote computer (possibly with a different name). For example, the following command copies file1 from the current directory at local host to file2 under the directory ~/dir1/ at the remote host remote_host:
$ scp file1 user@remote_host:~/dir1/file2
If you didn't want to save the file at the remote host with a different name you could have used simply the path where you wanted it to be saved, i.e.:
$ scp file1 user@remote_host:~/dir1/
[Command line] [Contents]


Graphical interface

Apart from Windows, all other Operating Systems (that I know) have built-in all the above commands, and hence you can access them by a terminal. You can download a recent release of the above programs from OpenSSH and fill in the gap of Windows. In this section I will give some links for graphical frontends of the above commands for the most popular Operating Systems: [Contents]

Windows

This is the webpage where you can download tools for Windows. PuTTY is the suggested application for having ssh under Windows, and you can download it here. Note that under the section Binaries there are two versions; the one on the first block is the latest release (but might be unstable), and the one on the second block which is a bit older but considered to be more stable. Choose whichever you like. I never had a serious problem with the unstable version. PuTTY is a superb program and it turns out that you don't need the rest of the files in that webpage.
The other thing that you need is a way to transfer files back and forth between different computers. The suggested method is WinSCP which you can download here. I suggest the standalone application, since it is the smallest one, does NOT require installation, and works flawlessly!
[Graphical interface] [Contents]

Unix/Linux

Have a look at gFTP which is a graphical sftp client. If the program is not installed on your system, you can install it (as root) with the command:
% apt-get install gftp
However, I don't think you can run gFTP in Plan 9 mainly because it seems that it lacks even a simple sftp client. On the other hand, Plan 9 supports ssh as it was described above on Command line. With MINIX things are much worse, since it seems that not even ssh is supported.
[Graphical interface] [Contents]

MacOS

gFTP which was suggested above can be installed in MacOS with MacPorts. First you have to install MacPorts and then install gFTP with the command (root shell):
% port install gftp
However, with much less hassle you can install two other very good programs; Cyberduck and Fugu. Cyberduck has a download link on the upper-right corner of the page, while nightly builds can be found here. Fugu on the other hand can be retrieved from here. Both of them can be used for sftp.
[Graphical interface] [Contents]



Back to Terminal's homepage Back to Dimitri's homepage

Last Update: Monday, January 28, 2008.