para simplificar la conexión vía SSH con diferentes servidores, y en alternativa a crear alias
de conexiones:
alias ssh-local-dns='ssh -v -i /home/mate/.ssh/pi@raspberry pi@192.168.1.60'
se puede optar por crear el fichero de configuración de conexión (~/.ssh/config
) e invocarlo:
ssh nombre_host
Include <FILE>
para fraccionar el fichero en otrosHost *
o Host *.dominio.com
o Host 192.168.10.?
para establecer opciones comunes a varios servidores.Host *.co.uk The following pattern would match any host in the 192.168.0.[0-9] network range: Host 192.168.0.? A pattern-list is a comma-separated list of patterns. Patterns within pattern-lists may be negated by preceding them with an exclamation mark (‘!’). For example, to allow a key to be used from anywhere within an organisation except from the “dialup” pool, the following entry (in authorized_keys) could be used: from="!*.dialup.example.com,*.example.com"
IdentitiesOnly=yes
# only use the authentication identity files configured in the ssh_config filesPreferredAuthentications=publickey
# Specifies the order in which the client should try protocol 2 authentication methods.«gssapi-with-mic, hostbased, publickey, keyboard-interactive, password»AddressFamily inet
# any, inet (IPv4), inet6 (IPv6)Protocol 2
Compression yes
ServerAliveInterval 60
ServerAliveCountMax 20
LogLevel INFO
dentro del fichero ~/.ssh/config
Host dev HostName dev.example.com Port 22000 User fooey
Host github.com User git HostName github.com IdentityFile ~/.ssh/my.key
git clone git@github.com:orgname/repository.git
#user1 account Host bitbucket.org-user1 HostName bitbucket.org User git IdentityFile ~/.ssh/user1 IdentitiesOnly yes #user2 account Host bitbucket.org-user2 HostName bitbucket.org User git IdentityFile ~/.ssh/user2 IdentitiesOnly yesSi se quiere automatizar el pull/push con diferentes cuentas se debe:
~/.ssh/config
git config user.name «user1»
git config user.email «user1@example.com»
git remote set-url origin git@bitbucket.org-user1:user1/your-repo-name.git
git clone git@bitbucket.org-user1:user1/your-repo-name.git
/via: https://developer.atlassian.com/blog/2016/04/different-ssh-keys-multiple-bitbucket-accounts/
Host tunnel HostName database.example.com IdentityFile ~/.ssh/other.key LocalForward 9906 127.0.0.1:3306 User fooeyequivaldría a:
ssh -f -N -L 9906:127.0.0.1:3306 fooey@database.example.com
y se ejecutaría:
ssh -f -N tunnel