2016-09-29 8 views
0

Попытка выполнить команду через ssh, но я ничего не получаю. Сервер A - это компьютер Solaris, а сервер B - это SUSE Linux с OpenBSD sshd. ПровереноУдаленная команда ssh не выполнена на openBSD

  1. ssh remote command does not return
  2. https://www.openbsd.org/papers/auug2002-ssh.pdf
  3. https://superuser.com/questions/792070/commands-over-ssh-not-producing-output

и другие источники, но не может решить.

Команда, которую я пытаюсь это (в Баш):

ssh -v -i .ssh/id_rsa -p1234 [email protected] 'ls' 

(пытался без кавычек и двойные кавычки, а)

, и информация отладки я получаю это:

Sun_SSH_1.1.6, SSH protocols 1.5/2.0, OpenSSL 0x0090704f 
    debug1: Reading configuration data /etc/ssh/ssh_config 
    debug1: Rhosts Authentication disabled, originating port will not be trusted. 
    debug1: ssh_connect: needpriv 0 
    debug1: Connecting to ABCDEFG [100.100.100.100] port 1234. 
    debug1: Connection established. 
    debug1: identity file ../../../.ssh/id_rsa type 1 
    debug1: Logging to host: abcdefg 
    debug1: Local user: user1 Remote user: user2 
    debug1: Remote protocol version 2.0, remote software version OpenSSH_6.2 
    debug1: match: OpenSSH_6.2 pat OpenSSH* 
    debug1: Enabling compatibility mode for protocol 2.0 
    debug1: Local version string SSH-2.0-Sun_SSH_1.1.6 
    debug1: use_engine is 'yes' 
    debug1: pkcs11 engine initialized, now setting it as default for RSA, DSA, and symmetric ciphers 
    debug1: pkcs11 engine initialization complete 
    debug1: Failed to acquire GSS-API credentials for any mechanisms (No credentials were supplied, or the credentials were unavailable or inaccessible 
Unknown code 0 
) 
    debug1: SSH2_MSG_KEXINIT sent 
    debug1: SSH2_MSG_KEXINIT received 
    debug1: kex: server->client aes128-ctr hmac-md5 none 
    debug1: kex: client->server aes128-ctr hmac-md5 none 
    debug1: Peer sent proposed langtags, ctos: 
    debug1: Peer sent proposed langtags, stoc: 
    debug1: We proposed langtags, ctos: i-default 
    debug1: We proposed langtags, stoc: i-default 
    debug1: SSH2_MSG_KEX_DH_GEX_REQUEST sent 
    debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP 
    debug1: dh_gen_key: priv key bits set: 128/256 
    debug1: bits set: 1014/2048 
    debug1: SSH2_MSG_KEX_DH_GEX_INIT sent 
    debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY 
    debug1: Host 'abcdefg' is known and matches the RSA host key. 
    debug1: Found key in /home/user1/.ssh/known_hosts:1 
    debug1: bits set: 1019/2048 
    debug1: ssh_rsa_verify: signature correct 
    debug1: newkeys: mode 1 
    debug1: set_newkeys: setting new keys for 'out' mode 
    debug1: SSH2_MSG_NEWKEYS sent 
    debug1: expecting SSH2_MSG_NEWKEYS 
    debug1: newkeys: mode 0 
    debug1: set_newkeys: setting new keys for 'in' mode 
    debug1: SSH2_MSG_NEWKEYS received 
    debug1: done: ssh_kex2. 
    debug1: send SSH2_MSG_SERVICE_REQUEST 
    debug1: got SSH2_MSG_SERVICE_ACCEPT 
    debug1: Authentications that can continue: publickey,password,keyboard-interactive 
    debug1: Next authentication method: publickey 
    debug1: Trying public key: .ssh/id_rsa 
    debug1: Server accepts key: pkalg ssh-rsa blen 149 lastkey 80b0320 hint 0 
    debug1: read PEM private key done: type RSA 
    debug1: Authentication succeeded (publickey) 
    debug1: SSH receive window size: 198720 B 
    debug1: channel 0: new [client-session] 
    debug1: send channel open 0 
    debug1: Entering interactive session. 
    debug1: ssh_session2_setup: id 0 
    debug1: Sending command: ls 
    debug1: channel request 0: exec 
    debug1: channel 0: open confirm rwindow 0 rmax 32768 
    debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 
    debug1: channel 0: rcvd eof 
    debug1: channel 0: output open -> drain 
    debug1: channel 0: obuf empty 
    debug1: channel 0: close_write 
    debug1: channel 0: output drain -> closed 
    debug1: channel 0: rcvd close 
    debug1: channel 0: close_read 
    debug1: channel 0: input open -> closed 
    debug1: channel 0: almost dead 
    debug1: channel 0: gc: notify user 
    debug1: channel 0: gc: user detached 
    debug1: channel 0: send close 
    debug1: channel 0: is dead 
    debug1: channel 0: garbage collecting 
    debug1: channel_free: channel 0: client-session, nchannels 1 
    debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.1 seconds 
    debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0 
    debug1: Exit status 1 

файл ssh_config на ServerB выглядит следующим образом:

#  $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $ 

# This is the sshd server system-wide configuration file. See 
# sshd_config(5) for more information. 

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin 

# Configuration file set-up to meet APG43L needs. 

Protocol 2 
PasswordAuthentication yes 
UsePAM yes 
################################################################################ 
# Access to sftp subsystem is DISABLED           # 
# Subsystem sftp internal-sftp             # 
################################################################################ 
PermitRootLogin no 
Ciphers aes128-ctr,aes256-ctr,arcfour256,arcfour,aes128-cbc,aes256-cbc 
PrintLastLog no 
Port 1234 


# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2 
# but this is overridden so installations will only check .ssh/authorized_keys 

AuthorizedKeysFile  .ssh/authorized_keys 

AllowGroups group1 group2 group3 
AllowUsers user2 
RSAAuthentication yes 
PubkeyAuthentication yes4 

EDIT: Я попытался выполнить команду на удаленной машине и перенаправить ее вывод в удаленный файл, но это тоже не сработает. Файл не создается (я могу записать этот файл в каталог, если я на удаленном сервере). Я также укрепил этот вопрос.

ssh -v -i .ssh/id_rsa -p1234 [email protected] 'ls > output.dat' 

ответ

0

Странно, конечно же не ваша команда - похожая на одинарные кавычки, работает для меня. Я получаю тот же отладочный вывод «debug1: Sending command: ls»), поэтому все аутентифицируется отлично, но вы просто не получаете результат, который я получаю!

Некоторые предполагает прибегая к помощи этой вариации на команды получает результаты

echo 'ls' | ssh -v -i .ssh/id_rsa -p1234 [email protected] 

https://superuser.com/questions/792070/commands-over-ssh-not-producing-output

Я предполагаю, что у вас есть исполняемые права на свой домашний каталог (удивлен, если вы не делали) ... но предположение является матерью всех бэков, так что проверьте, действительно ли вы на самом деле на самом деле.

+0

Я тоже попытался повторить это. (Я упоминал этот вопрос/ссылку в разделе «Работа на дому»;)). Я получил: «Псевдо-терминал не будет выделен, потому что stdin не является терминалом». Я действительно озадачен. – taiko

+0

, даже используя параметр -T, который отключит выделение псевдо TTY? Тогда yep, действительно озадачив –

+0

с опцией -T вместе с echo 'ls. Я не получу эту ошибку «Pseudo ...», но не получаю ничего другого – taiko