3. Acceso remoto

Win Lin Win-VM-Lin Win-WM-Win Lin-WM-Lin Lin-WM-Win
Win A B ??? ??? B* B*
Lin C D ??? ??? D* D*
And ??? ??? ??? ??? ??? ???

Nautilus? Dolphin?

A: Win-Win

Acceso a directorios:

Escritorio remoto:

Ejecución de aplicaciones

???

B: Win-Lin

Además de las aplicaciones específicas para Windows, los siguientes proyectos permiten ejecutar algunas comunes en entornos GNU/Linux:

Salvo que se indique lo contrario, a lo largo de esta la sección (Win-Lin) se presupone que se está utilizando alguna de las soluciones de terminal anteriores.

Secure Shell - SSH

SSH es un protocolo para acceder a máquinas remotas a través de una red. Permite manejar por completo el host mediante un intérprete de comandos, y también puede redirigir el tráfico de X para poder ejecutar programas gráficos. Además, permite copiar datos de forma segura, gestionar claves RSA para no escribir claves al conectar a los dispositivos y pasar los datos de cualquier otra aplicación por un canal seguro tunelizado mediante SSH.

La implementación libre por excelencia es OpenSSH, que incluye:

Dropbear SSH es una alternativa a OpenSSH en entornos empotrados (con pocos recursos de memoria y/o procesamiento). Es un componente de OpenWrt, por ejemplo.

Configuración del host - sshd

Para poder acceder a un equipo mediante SSH, en éste debe estar corriendo sshd. Para lanzarlo, basta con ejecutar el comando sshd <rutadesshd> (sshd re-exec requires execution with an absolute path). Para no tener que hacerlo después de cada reinicio, puede incluirse como servicio en la distribución que estemos utilizando (p. ej. docs.fedoraproject.org - Starting an OpenSSH Server), lo que nos ofrecerá mayores posibilidades de monitorización y registro.

En un entorno de pruebas no reviste mayor gravedad, pero antes de dejar el servicio corriendo en un equipo sensible, debe revisarse la configuración en /etc/ssh/sshd_config. Puede utilizarse cualquier editor de texto, pero se requieren permisos de administración. Algunos de los campos a tener en consideración son:

ssh-keygen

Las parejas de claves de un usuario se almacenan por defecto en ~/.ssh/. Se puede consultar si existe alguna mediante ls -la ~/.ssh en la terminal, o a través de un explorador gráfico. Cada pareja se almacenan en dos ficheros con el mismo nombre: la clave privada no tiene extensión, y la pública termina en .pub.

ssh-keygen permite generar parejas de claves mediante un comando, donde se indican el tipo de algoritmo (RSA vs DSA vs ECDSA vs Ed25519), la longitud en bits, y un comentario para identificar la pareja (una dirección de e-mail, por ejemplo):

$ cd ~/.ssh
$ ssh-keygen -t rsa -b 4096 -C "<comment>"
Enter file in which to save the key (/<homedelusuario>/.ssh/id_rsa): [introducir ruta y nombre, y/o presionar enter]
Enter passphrase (empty for no passphrase): [introducir contraseña]
Enter same passphrase again: [introducir contraseña de nuevo]
Your identification has been saved in /<homedelusuario>/.ssh/<nombredelapareja>.
Your public key has been saved in /<homedelusuario>/.ssh/<nombredelapareja>.pub.
The key fingerprint is:
SHA256:4Jcm185Eiz+wAgzRR0Uw2yADR5ewvpu26XtxlEP+53I <comment>
The key's randomart image is:
+---[RSA 4096]----+
|  o+*o*=o        |
|   o.=o=.        |
|  . ..oo...      |
|   + . .== .     |
|    + o.So+      |
|     o.=.B. .    |
|    . .o. =o     |
|    .+..  ..E    |
|   oB+     o     |
+----[SHA256]-----+

Alternativamente, puede generarse la pareja en cualquier otro directorio, y moverlas después. Pero no es recomendable generar la pareja en un dispositivo y mover la privada a otro.

La contraseña (passphrase) introducida se utiliza para cifrar simétricamente la clave privada, de forma que no pueda utilizarse por terceros sólo con tener acceso al contenido del fichero. Esta contraseña puede cambiarse más tarde, ya que es recomendable renovarla periódicamente:

$ ssh-keygen -f <nombredelapareja> -p

No es necesaria para, por ejemplo, comprobar la integridad del contenido recibido. Se solicitará cada vez que se quiera firmar un contenido. Es personal y debe protegerse. Nunca se debe facilitar esta contraseña a otros usuarios. En cualquier caso, es sólo una capa de seguridad, por lo que sigue siendo importante gestionar con cuidado las copias de la clave privada.

$ cat ~/.ssh/<nombredelapareja>
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,4489C37536197E54D83CC048A4C438A8

ukL2odx5NHDxYt2ONMDvi0mMRVX8hTneEYXkhpLyEVgWBsV++jNWY69BX8StoCMV
pj4Xo5dm4suAGFsxlsgg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tDhHNyg//RJ6tC8hL2Bop5NTyp6B
7hd/mT8TetA8a0SZgRF3bRfeOBgOLjXw6z0uRajtneFQixPhNskN0waFqKDqLgis
SZWPssiPWbhnyJvSKS+2TGMYjP/dFnxFLWZ2JJjICe3z67uShWWYry+JJQNxe01M
Bu1N23bIuRzZqEdKtYnr6gcGzfY1lah4flLW7PJnZPkKlbOev6y1x5JVaGG3P8sR
e0Q4imYhV3Kv280H0KncQzARgz6YceaGXb9C/Wud+llRFN1a9+hiPExLEYd0NUWc
ti004zFdYZ2rb20iLX7c4gXyM6tFKmed1rejnRQFa+N5QHNYCLM9+5/UACISQohu
064pvdIPHFhnb8qRp3hlWwzqXTBR/Hk5zAQhm0aqWRyYXKSZvC0DXSrtxX8XQ95X
qkJSxbJoi66qtOLtqbaF/qhWHibMrYGfs2V5jjSbhOjLtW8nH7u94EeXhL/W66Qf
LucGlCn7DiEXUxBdySeiPBecN32uGmAwu/cF+Yg0XI6AUEZ68Ow3U3fmljxBDL2f
yRfuXRVXu3TTRcRLSEDjK/aEO/t7xG/I9uhP8yfc4n6y8//wfzTefOubXnv9HuNL
tnV5VbVIZ96h6TRe4N5f8xqUUBBOM3EIi4PFqQq/lsOTRTTy7C3SJM4V832WIl2k
b1DMxMO9a/5nnfuva8oY1cRrCS2glSOucVx3nFOzSef0ylpVZ74GgcC92Sy+1FbR
oP7l55/qp1bOmhExdS8pz6gyZCNfWqSX0YIuo4kuWkJUDCJA33YwyTiWduD9tXB2
dZO6H+i8r7+L9jOdGD2b3XCrg/onfYdRsrknjAoJRsUsJo09P9laEuXPPROW6BIQ
6n2JGE8S5U4VPBWnBw1GnBFXXyaASIfX5NiqlJDmbBdbq1p+rckglN4MWWZcAGvc
-----END RSA PRIVATE KEY-----
ssh-copy-id

Para que un host permita el acceso mediante SSH a un usuario, la clave pública de éste debe estar en el fichero ~/.ssh/authotized_keys. Puesto que se trata de una clave pública, puede transferirse al servidor por el medio deseado.

$ cat ~/.ssh/<nombredelapareja>.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCy9bZvN2IfzBU0brJHlXqAPE85+mZPtGULHjiFDilNZ3ZwdkMvfdPKabNzVaxabBaS60HXB2EhKHfD6sF/bX88U9SeWxpNOhbolDLBW/gkVL68EvOHghsYZRwTXhJmT/j9piIOC6T7bnZD7nCC4Je6MRjOCyNf7pYqeZfRuJV0D0txKT5NaCH92SwiIqBrBYw8xWSfFdYcVneZKRT0StylXVl3wWL1+Zw/DnctJVaUEVqM800OguG5ujAl27LyhNj0HQOBVlXOGS4SXUYtXkA2a6lv/uDjI8fjd0DkSsdzVsLridzumxAo8uWr/C9B89T7HUMAOD7iNQfTkK5nrd6KF0gVYJl5OSoDAsHe/vhfg+DbbQf68MlZAnBioWY+mcQ4ffWHYL2kVy5N4XHNCnRfmCMiC8cLh/zNs7IVzE1CSMVyE2sMLCG3gfU7UqEX0CWoNyq5AKpeMZ6qKhIGXrLAogSVs45WQ+qkX/lAJp2yyofMtxjyV08SAE++CDgml8yF3xgO0zgh8IUe7t2ZGOeaJ4OoffL5RDCkAybVdRBdaCoo/EEn4qzptSIhWh4uyN/IvyVaGEQT+CPgD19mB6GMBdjsbH+KAGO+zIehVxfcMPj035vxuLWkQk/yUMeGRyqyBVsJWau2ZfIOCY+EyvOUTT0yKsnBvKovcLae5+Z1zQ== <comment>

Se puede añadir la clave nueva a authorized_keys mediante cualquier editor de texto, o directamente en la terminal:

$ cat <nombredelapareja>.pub >~/.ssh/authorized_keys   # Borrar el contenido anterior
$ cat <nombredelapareja>.pub >>~/.ssh/authorized_keys  # Mantener el contenido anterior y copiar al final

Para facilitar la tarea anterior, en caso de disponer de acceso por contraseña, puede utilizarse ssh-copy-id:

$ ssh-copy-id [-i [<nombredelapareja>.pub]] [<usuario>@]<nombreoipdelhost> [-p <puerto>]    
ssh-agent

Como resulta tedioso introducir continuamente la contraseña (passphrase) cuando se establecen conexiones continuamente, ssh-agent permite introducirla una sola vez. Crea un proceso que guarda la clave privada desencriptada en memoria, y se comunica con los clientes SSH utilizando un socket Unix.

$ eval $(ssh-agent -s)
$ ssh-add ~/.ssh/<nombredelapareja>

En caso de querer ejecutar ssh-agent y añadir la clave cada vez que se inicie la terminal, se pueden añadir las líneas anteriores al fichero ~/.bashrc. Más información en Could not open a connection to your authentication agent y ssh-agent-snippets.sh .

Configuración del cliente

Para iniciar una sesión en un host es recomendable disponer previamente de su clave pública y añadirla al fichero ~/.ssh/known_hosts. Si no, la primera vez que se trate de realizar una conexión se mostrará un aviso y se pedirá confirmación para añadirla automáticamente.

$ ssh [<usuario>@]<nombreoipdelhost> [-p <puerto>] [-i <nombredelapareja>.pub]

En caso de que se utilicen el puerto por defecto (22), el nombre y ubicación por defecto (~/.ssh/id_rsa.pub), y el usuario local sea igual que el del host, se puede resumir en:

$ ssh <nombreoipdelhost>

En cualquier caso, resulta tedioso tener que recordar las opciones y parámetros para cada host. La edición del fichero de configuración local (~/.ssh/config) nos permite establecer alias para los host:

Host <alias>
  HostName <nombreoipdelhost>
  Port <puerto>
  User <usuario>
  IdentityFile /<homedelusuario/.ssh/<nombredelapareja>.pub

P: ¿Una pareja de claves por usuario? ¿por host? ¿por cliente? ¿por servicio?

P: ¿Smartcards? ¿Tokens?

P: ¿Man in the middle - MITM?

Acceso a directorios

  • Compared to the Secure Copy Protocol - SCP , which only allows file transfers, the SSH File Transfer Protocol - SFTP allows for a range of operations on remote files which make it more like a remote file system protocol (resuming interrupted transfers, directory listings, remote file removal…). SFTP attempts to be more platform-independent than SCP; with SCP, for instance, the expansion of wildcards specified by the client is up to the server, whereas SFTP’s design avoids this problem. While SCP is most frequently implemented on Unix platforms, SFTP servers are commonly available on most platforms.

  • SFTP is sometimes confused with Simple File Transfer Protocol, which was proposed as an (unsecured) file transfer protocol with a level of complexity intermediate between TFTP and FTP.

  • While SFTP clients may transfer files and directories, the related file system may not be mounted locally using SFTP alone. Using SSH Filesystem SSHFS, a remote file system may be treated in the same way as other volumes (such as CDs, DVDs, USB flash drives and shared disks), providing secure file transfer and a secure remote file system.

  • SFTP usually only requires the SSH port for both data and control, but FTP over TLS/SSL - FTPS uses a control channel and opens new connections for the data transfer. As it uses SSL, FTPS requires a certificate, that may need the additional configuration of a supported FTP server (más info).

scp
scp [-v] -r [-P 2200] <origen> <destino>

$user@$host:$dest

cygwin
mingw
WinSCP

Aunque el nombre pueda dar lugar a equívoco, soporta SFTP.

winscp
dokan-sshfs
FileZilla

Escritorio remoto

https://en.wikipedia.org/wiki/Virtual_Network_Computing

By default, RFB is not a secure protocol. While passwords are not sent in plain-text (as in telnet), cracking could prove successful if both the encryption key and encoded password are sniffed from a network. For this reason it is recommended that a password of at least 8 characters be used. On the other hand, there is also an 8-character limit on some versions of VNC; if a password is sent exceeding 8 characters, the excess characters are removed and the truncated string is compared to the password.

UltraVNC supports the use of an open-source encryption plugin which encrypts the entire VNC session including password authentication and data transfer. It also allows authentication to be performed based on NTLM and Active Directory user accounts. However, use of such encryption plugins make it incompatible with other VNC programs. RealVNC offers high-strength AES encryption as part of its commercial package, along with integration with Active Directory. Workspot released AES encryption patches for VNC. According to TightVNC,[12] TightVNC is not secure as picture data is transmitted without encryption. To circumvent this, it should be tunneled through a SSH connection (see below).

VNC may be tunnelled over an SSH or VPN connection which would add an extra security layer with stronger encryption. SSH clients are available for most platforms; SSH tunnels can be created from UNIX clients, Microsoft Windows clients, Macintosh clients (including Mac OS X and System 7 and up) – and many others. There are also freeware applications that create instant VPN tunnels between computers.

An additional security concern for the use of VNC is to check whether the version used requires authorization from the remote computer owner before someone takes control of her device. This will avoid the situation where the owner of the computer accessed realizes there is someone in control of her device without previous notice.

VNC
RDP
ssh -X

Ejecución de aplicaciones

putty
screen
nohup

C

SMB/CIFS https://en.wikipedia.org/wiki/Server_Message_Block

sudo mkdir -p /run/media/1138-4EB/CLIFF
sudo mount -t cifs //158.227.72.111/Unai_Martinez -o username=Unai /run/media/1138-4EB/CLIFF/

http://www.seas.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html#ssh-win

http://techtorials.me/cygwin/sshd-configuration/

http://www.osmanoglu.org/computing/31-tunnelingsambathroughssh

D

http://fuse.sourceforge.net/sshfs.html

*