Posts Tagged Redes

Using SSH


If you are working in a networking environment, more likely you’ll need servers, run commands or copy files remotely and safely. For this you count on with the ssh protocol which allows you exchange data between devices through a secure channel, using public key cryptography to authenticate remote computers and users. Some features that offers ssh are:

  • It allows you to mange computer remotely.
  • It can be used as an FTP alternative (using SFTP).
  • It the replacement of the r commands (rcp, rsh, rlogin and telnet).
  • It allows you to redirect ports and tunneling.
  • It can be used to run commands on remote servers.
  • It allows to run graphical applications in a remote server and display them in the local computer.
  • By default it listens on the TCP port 22.

Installing SSH

On Debian you can install the server and the client as follow:

aptitude install openssh-client openssh-server

Accessing remote servers

In order to access a remote server using an IP address, you can do the following:

ssh user@

Where must be a address associated to an IP address by and DNS or through the /etc/hosts file. In the other hand, if the current account exists in server and client, you can omit the user name and the current working user will be assumed:


Running commands remotely

In order to run a command remotely, you can use this syntax:

ssh command
ssh user@ command

Where command refers to the command or absolute path of the program to run. Examples:

ssh /usr/local/bin/backup
ssh user@ ls > listing.tx

Running graphical applications remotely

Sometimes you need to run graphical applications  on remote server but display them on locally. You can achieve this with ssh by using the -X switch:

ssh -X application
ssh -X user@ application

For instance, if you want to run Firefox from a remote server you can type the following:

ssh -X lgallard@ firefox

Note: In order to display graphical applications remotely, the client must enable the following option in the /etc/ssh/sshd_config file:

X11Forwarding yes

Copying files remotely

Sooner or later you will need to copy files among working stations and, to avoid  copy them on temporary media (like pendrives), you can copy directly from one device to another. To do so, follow this syntax:

Copy from a local computer to a remote server:

scp /local/path/to/file
scp /local/path/to/file user@


scp /etc/passwd lgallard@

Copying from a remote server to a local computer::

scp /local/path
scp /local/path


scp root@ .