Skip to content

Instantly share code, notes, and snippets.

@aduartem
Last active February 22, 2016 02:34
Show Gist options
  • Save aduartem/c4fd3b641e93a437bc3b to your computer and use it in GitHub Desktop.
Save aduartem/c4fd3b641e93a437bc3b to your computer and use it in GitHub Desktop.
SSH en Linux

ssh

Cómo instalar un servidor SSH ubuntu

Para instalar el servidor ssh:

$ sudo apt-get install openssh-server

Para configurar el servidor editamos el archivo /etc/ssh/sshd_config

$ sudo vim /etc/ssh/sshd_config

Para reiniciar el servicio

$ sudo /etc/init.d/ssh restart

Autenticación con ssh usando llave pública

Generar llave pública ssh

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/jperez/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/jperez/.ssh/id_rsa.
Your public key has been saved in /Users/jperez/.ssh/id_rsa.pub.
The key fingerprint is:
43:c5:5b:5f:b1:f1:50:43:ad:20...

En el servidor autorizar llave para acceso por ssh

Abrir el archivo authorized_keys

$ vim ~/.ssh/authorized_keys

y agregar la llave pública en una nueva línea, al final del archivo.

$ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC87RpU... jperez@example.com

Iniciar sesión en un servidor remoto

Sintaxis:

$ ssh -p puerto usuario@host

Ejemplo:

$ ssh -p 14225 sistemas@192.168.1.4

Sintaxis opcional:

$ ssh -l usuario -p puerto host

Ejemplo:

$ ssh -l sistemas -p 14225 192.168.1.4

SCP

Permite copiar archivos entre dos máquinas. Utiliza ssh para las transferencia de datos, por tanto ofrece la misma seguridad que el ssh. Utiliza ssh para iniciar sesión. Este comando reemplaza rcp y ftp.

Sintaxis:

scp -P puerto archivo usuario@host:/ruta_destino

Ejemplo:

$ scp -P 14225 dec5.tar sistemas@192.168.1.4:/opt/dec5

$ scp -P 14225 /home/cmarquez/dev/php/dec5.tar sistemas@192.168.1.4:/opt/dec5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment