Для этого существует альтернативный способ, который называется .ssh/config
создайте файл с именем .ssh/config с правкой ниже
Host Server-Jump-*
User username
IdentityFile ~/.ssh/id_rsa # -- if you want to provide key
ForwardAgent yes
ServerAliveInterval 60
ServerAliveCountMax 12
Host Server1
Hostname 21.19.6.19
Port 2222
Host Server2
Hostname Server2-IP
Port 22
ProxyCommand ssh -W %h:%p Server1
Сохраните этот файл.
Теперь попробуйте следующую команду
ssh Server2
Описание команды proxy в разделе
-W host:port
Requests that standard input and output on the client be forwarded to host on port over the secure channel. Implies -N, -T, ExitOnForwardFailure and ClearAllForwardings. Works
with Protocol version 2 only.
`%h` Host name to connect
`%p` Port name to connect
El guión solo tiene un significado especial cuando no es el primer o último carácter en una clase de caracteres entre paréntesis.
[a-z]
coincide con todas las letras minúsculas ASCII -de a
a z
. [-a-z]
coincide con todas las letras minúsculas ASCII -de a
az
y el guión -
.
Esto está documentado en la documentación de Perl:
Within a list, the "-" character specifies a range of characters, so that a-z represents all characters between "a" and "z", inclusive. If you want either "-" or "]" itself to be a member of a class, put it at the start of the list (possibly after a "^" ), or escape it with a backslash. "-" is also taken literally when it is at the end of the list, just before the closing "]".
El signo menos al principio se usa para incluir el carácter literal menos en el grupo. También podría ser al final del grupo. Comparar:
$ echo abc- | grep [w-x]
$ echo abc- | grep [w-x-]
abc-
$ echo abc- | grep [-w-x]
abc-
Cuando no está al principio ni al final, su función es describir un rango, como en w-x
.