Posts Tagged Redes
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.
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 [email protected] ssh [email protected]
Where server.com 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 [email protected] command ssh [email protected] command
Where command refers to the command or absolute path of the program to run. Examples:
ssh [email protected] /usr/local/bin/backup ssh [email protected] 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 [email protected] application ssh -X [email protected] application
For instance, if you want to run Firefox from a remote server you can type the following:
ssh -X [email protected] firefox
Note: In order to display graphical applications remotely, the client must enable the following option in the /etc/ssh/sshd_config file:
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 [email protected]:/remote/path scp /local/path/to/file [email protected]:/remote/path
scp /etc/passwd [email protected]:/home/lgallard/Desktop
Copying from a remote server to a local computer::
scp [email protected]:/remote/path/to/file /local/path scp 192.168.1.30:/remote/path/to/file /local/path
scp [email protected]:/etc/shadow .
- Secure Shell en Wikipedia
- man ssh