SSH на удаленную машину, используя другой локальный ID

Вы можете получить эту информацию на своем локальном компьютере, выполнив поиск по запросу $ ( на странице Bash man :

tomas@tomas-Latitude-E4200:~$ man bash | grep -A2 -B2 '$('
       If value is not given, the variable is assigned the null string.  All values undergo tilde expansion, parameter and variable expansion, command sub‐
       stitution, arithmetic expansion, and quote removal (see EXPANSION below).  If the variable has its integer attribute set, then value is evaluated as
       an  arithmetic  expression  even  if the $((...)) expansion is not used (see Arithmetic Expansion below).  Word splitting is not performed, with the
       exception of "$@" as explained below under Special Parameters.  Pathname expansion is not performed.  Assignment statements may also appear as argu‐
       ments  to  the  alias,  declare,  typeset, export, readonly, and local builtin commands.  When in posix mode, these builtins may appear in a command
--
       Command substitution allows the output of a command to replace the command name.  There are two forms:

              $(command)
       or
              `command`

       Bash  performs  the expansion by executing command and replacing the command substitution with the standard output of the command, with any trailing
       newlines deleted.  Embedded newlines are not deleted, but they may be removed during word splitting.  The command substitution $(cat  file)  can  be
       replaced by the equivalent but faster $(< file).

       When  the  old-style  backquote  form  of substitution is used, backslash retains its literal meaning except when followed by $, `, or \.  The first
       backquote not preceded by a backslash terminates the command substitution.  When using the $(command) form, all characters between  the  parentheses
       make up the command; none are treated specially.

--
       Arithmetic expansion allows the evaluation of an arithmetic expression and the substitution of the result.  The format for arithmetic expansion is:

              $((expression))

       The old format $[expression] is deprecated and will be removed in upcoming versions of bash.

Может потребоваться некоторая корректировка для -A Параметры и -B . Они устанавливают контекст до и после и зависят от самой страницы man , ее содержимого, а также от дисплея терминала - сколько он отображает в каждой строке. Поэтому вам нужно смотреть на то, что вы видите, и думать о том, что вы хотите видеть.

Но результат может быть полезным. Это ключевой отрывок из первого списка:

       Command substitution allows the output of a command to replace the command name.  There are two forms:

              $(command)
       or
              `command`
2
17.11.2018, 03:16
2 ответа

Скопируйте закрытый ключ пользователя2 пользователю1:

cp /home/user2/.ssh/id_rsa     /home/user1/.ssh/id_rsa.user2
cp /home/user2/.ssh/id_rsa.pub /home/user1/.ssh/id_rsa.user2.pub
chown user1:group1 /home/user1/.ssh/id_rsa.user2{,.pub}

Как пользователь1, подключитесь с этой альтернативной идентификацией:

ssh -i /home/user1/.ssh/id_rsa.user2

Или добавьте запись хоста в /home/user1/.ssh/config

Host B
  IdentityFile /home/user1/.ssh/id_rsa.user2
2
27.01.2020, 22:11

"Доверие отношений" неизвестно в мире unix. Нам известны sudo или ssh без пароля.

Вы не можете легко получить трехступенчатое «доверие» (user1 @ A -> user2 @ A -> remoteuser @ B).

либо

  1. сценарий передачи пользователю 2
  2. разрешить пользователю 1 использовать sudo без пароля для пользователя 2
  3. разрешить пользователю 1 без пароля входить в систему Б в качестве удаленного пользователя

Вам необходимо отредактировать /etc/sudoers.conf или скопируйте закрытый ключ пользователя user2 в ключ пользователя user1.

0
27.01.2020, 22:11

Теги

Похожие вопросы