diff --git a/apps/smart-ssh-community/frontend/src/api/errorCodes.ts b/apps/smart-ssh-community/frontend/src/api/errorCodes.ts index 016b800b6..2802e0084 100644 --- a/apps/smart-ssh-community/frontend/src/api/errorCodes.ts +++ b/apps/smart-ssh-community/frontend/src/api/errorCodes.ts @@ -64,6 +64,9 @@ const KNOWN_ERROR_CODES = new Set([ "SSH_AUTH_FAILED", "SSH_HOST_KEY_REJECTED", "SSH_CHANNEL_ERROR", + // Issue #1665: the server refused the shell / exec request. + "SSH_SHELL_UNAVAILABLE", + "SSH_EXEC_UNAVAILABLE", "SSH_TIMEOUT", "SSH_JUMP_HOST_CYCLE", "SSH_CREDENTIAL_RESOLUTION_FAILED", diff --git a/apps/smart-ssh-community/frontend/src/locales/cs/common.json b/apps/smart-ssh-community/frontend/src/locales/cs/common.json index d3fb9c2ba..61fb22629 100644 --- a/apps/smart-ssh-community/frontend/src/locales/cs/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/cs/common.json @@ -616,6 +616,8 @@ "SSH_AUTH_FAILED": "Přihlášení odmítnuto. Zkontrolujte uživatelské jméno a heslo nebo klíč v nastavení serveru.", "SSH_HOST_KEY_REJECTED": "Klíč hostitele odmítnut", "SSH_CHANNEL_ERROR": "Chyba kanálu", + "SSH_SHELL_UNAVAILABLE": "Server pro toto přihlášení nenabízí interaktivní shell.", + "SSH_EXEC_UNAVAILABLE": "Server pro toto přihlášení nepovoluje spouštění příkazů.", "SSH_TIMEOUT": "Server neodpovídá. Zkontrolujte adresu, port a firewall a připojte se znovu.", "SSH_JUMP_HOST_CYCLE": "Zjištěn cyklický řetězec jump hostů", "SSH_CREDENTIAL_RESOLUTION_FAILED": "Přihlašovací údaje se nepodařilo zjistit", diff --git a/apps/smart-ssh-community/frontend/src/locales/da/common.json b/apps/smart-ssh-community/frontend/src/locales/da/common.json index e455477af..f0e439a82 100644 --- a/apps/smart-ssh-community/frontend/src/locales/da/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/da/common.json @@ -612,6 +612,8 @@ "SSH_AUTH_FAILED": "Login afvist. Kontrollér brugernavn og adgangskode eller nøgle i serverindstillingerne.", "SSH_HOST_KEY_REJECTED": "Værtsnøgle afvist", "SSH_CHANNEL_ERROR": "Kanalfejl", + "SSH_SHELL_UNAVAILABLE": "Serveren tilbyder ikke en interaktiv shell til dette login.", + "SSH_EXEC_UNAVAILABLE": "Serveren tillader ikke at køre kommandoer for dette login.", "SSH_TIMEOUT": "Serveren svarer ikke. Kontrollér adresse, port og firewall, og opret derefter forbindelse igen.", "SSH_JUMP_HOST_CYCLE": "Cirkulær jump-vært-kæde registreret", "SSH_CREDENTIAL_RESOLUTION_FAILED": "Legitimationsoplysninger kunne ikke opløses", diff --git a/apps/smart-ssh-community/frontend/src/locales/de/common.json b/apps/smart-ssh-community/frontend/src/locales/de/common.json index 904ca9b66..728f00fbc 100644 --- a/apps/smart-ssh-community/frontend/src/locales/de/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/de/common.json @@ -612,6 +612,8 @@ "SSH_AUTH_FAILED": "Anmeldung abgelehnt. Benutzername und Passwort bzw. Schlüssel in den Server-Einstellungen prüfen.", "SSH_HOST_KEY_REJECTED": "Host-Key abgelehnt", "SSH_CHANNEL_ERROR": "Verbindungskanal-Fehler", + "SSH_SHELL_UNAVAILABLE": "Der Server bietet für diese Anmeldung keine interaktive Shell an.", + "SSH_EXEC_UNAVAILABLE": "Der Server erlaubt für diese Anmeldung keine Befehlsausführung.", "SSH_TIMEOUT": "Der Server antwortet nicht. Adresse, Port und Firewall prüfen und erneut verbinden.", "SSH_JUMP_HOST_CYCLE": "Zyklische Jump-Host-Kette erkannt", "SSH_CREDENTIAL_RESOLUTION_FAILED": "Zugangsdaten konnten nicht aufgelöst werden", diff --git a/apps/smart-ssh-community/frontend/src/locales/el/common.json b/apps/smart-ssh-community/frontend/src/locales/el/common.json index 3cfb662e6..caf55fcec 100644 --- a/apps/smart-ssh-community/frontend/src/locales/el/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/el/common.json @@ -612,6 +612,8 @@ "SSH_AUTH_FAILED": "Η σύνδεση απορρίφθηκε. Ελέγξτε το όνομα χρήστη και τον κωδικό ή το κλειδί στις ρυθμίσεις του διακομιστή.", "SSH_HOST_KEY_REJECTED": "Το κλειδί κεντρικού υπολογιστή απορρίφθηκε", "SSH_CHANNEL_ERROR": "Σφάλμα καναλιού", + "SSH_SHELL_UNAVAILABLE": "Ο διακομιστής δεν προσφέρει διαδραστικό shell για αυτή τη σύνδεση.", + "SSH_EXEC_UNAVAILABLE": "Ο διακομιστής δεν επιτρέπει την εκτέλεση εντολών για αυτή τη σύνδεση.", "SSH_TIMEOUT": "Ο διακομιστής δεν ανταποκρίνεται. Ελέγξτε τη διεύθυνση, τη θύρα και το τείχος προστασίας και συνδεθείτε ξανά.", "SSH_JUMP_HOST_CYCLE": "Εντοπίστηκε κυκλική αλυσίδα ενδιάμεσων διακομιστών", "SSH_CREDENTIAL_RESOLUTION_FAILED": "Η ανάκτηση των διαπιστευτηρίων απέτυχε", diff --git a/apps/smart-ssh-community/frontend/src/locales/en/common.json b/apps/smart-ssh-community/frontend/src/locales/en/common.json index 58e274588..dfb4c521b 100644 --- a/apps/smart-ssh-community/frontend/src/locales/en/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/en/common.json @@ -612,6 +612,8 @@ "SSH_AUTH_FAILED": "Login rejected. Check the user name and password or key in the server settings.", "SSH_HOST_KEY_REJECTED": "Host key rejected", "SSH_CHANNEL_ERROR": "Channel error", + "SSH_SHELL_UNAVAILABLE": "The server does not offer an interactive shell for this login.", + "SSH_EXEC_UNAVAILABLE": "The server does not allow running commands for this login.", "SSH_TIMEOUT": "The server isn't responding. Check address, port and firewall, then connect again.", "SSH_JUMP_HOST_CYCLE": "Cyclic jump host chain detected", "SSH_CREDENTIAL_RESOLUTION_FAILED": "Failed to resolve credentials", diff --git a/apps/smart-ssh-community/frontend/src/locales/es/common.json b/apps/smart-ssh-community/frontend/src/locales/es/common.json index ed02e92cc..0625cc13c 100644 --- a/apps/smart-ssh-community/frontend/src/locales/es/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/es/common.json @@ -614,6 +614,8 @@ "SSH_AUTH_FAILED": "Inicio de sesión rechazado. Compruebe el usuario y la contraseña o la clave en los ajustes del servidor.", "SSH_HOST_KEY_REJECTED": "Clave de host rechazada", "SSH_CHANNEL_ERROR": "Error de canal", + "SSH_SHELL_UNAVAILABLE": "El servidor no ofrece un shell interactivo para este inicio de sesión.", + "SSH_EXEC_UNAVAILABLE": "El servidor no permite ejecutar comandos con este inicio de sesión.", "SSH_TIMEOUT": "El servidor no responde. Compruebe la dirección, el puerto y el cortafuegos y vuelva a conectar.", "SSH_JUMP_HOST_CYCLE": "Se detectó una cadena cíclica de hosts de salto", "SSH_CREDENTIAL_RESOLUTION_FAILED": "Error al resolver las credenciales", diff --git a/apps/smart-ssh-community/frontend/src/locales/fi/common.json b/apps/smart-ssh-community/frontend/src/locales/fi/common.json index ce68fc4a8..7668b4c1a 100644 --- a/apps/smart-ssh-community/frontend/src/locales/fi/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/fi/common.json @@ -612,6 +612,8 @@ "SSH_AUTH_FAILED": "Kirjautuminen hylättiin. Tarkista käyttäjätunnus ja salasana tai avain palvelimen asetuksista.", "SSH_HOST_KEY_REJECTED": "Isäntäavain hylätty", "SSH_CHANNEL_ERROR": "Kanavavirhe", + "SSH_SHELL_UNAVAILABLE": "Palvelin ei tarjoa interaktiivista komentotulkkia tälle kirjautumiselle.", + "SSH_EXEC_UNAVAILABLE": "Palvelin ei salli komentojen suorittamista tällä kirjautumisella.", "SSH_TIMEOUT": "Palvelin ei vastaa. Tarkista osoite, portti ja palomuuri ja yhdistä uudelleen.", "SSH_JUMP_HOST_CYCLE": "Hyppypalvelinketjussa havaittiin silmukka", "SSH_CREDENTIAL_RESOLUTION_FAILED": "Tunnistetietojen selvitys epäonnistui", diff --git a/apps/smart-ssh-community/frontend/src/locales/fr/common.json b/apps/smart-ssh-community/frontend/src/locales/fr/common.json index d395624df..cca75598b 100644 --- a/apps/smart-ssh-community/frontend/src/locales/fr/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/fr/common.json @@ -614,6 +614,8 @@ "SSH_AUTH_FAILED": "Connexion refusée. Vérifiez le nom d’utilisateur et le mot de passe ou la clé dans les paramètres du serveur.", "SSH_HOST_KEY_REJECTED": "Clé d’hôte rejetée", "SSH_CHANNEL_ERROR": "Erreur de canal", + "SSH_SHELL_UNAVAILABLE": "Le serveur ne propose pas de shell interactif pour cette connexion.", + "SSH_EXEC_UNAVAILABLE": "Le serveur n'autorise pas l'exécution de commandes pour cette connexion.", "SSH_TIMEOUT": "Le serveur ne répond pas. Vérifiez l’adresse, le port et le pare-feu, puis reconnectez-vous.", "SSH_JUMP_HOST_CYCLE": "Chaîne d’hôtes de rebond cyclique détectée", "SSH_CREDENTIAL_RESOLUTION_FAILED": "Échec de la résolution des identifiants", diff --git a/apps/smart-ssh-community/frontend/src/locales/hi/common.json b/apps/smart-ssh-community/frontend/src/locales/hi/common.json index 0f1b48a38..ceaf92e52 100644 --- a/apps/smart-ssh-community/frontend/src/locales/hi/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/hi/common.json @@ -612,6 +612,8 @@ "SSH_AUTH_FAILED": "लॉगिन अस्वीकृत। सर्वर सेटिंग्स में उपयोगकर्ता नाम और पासवर्ड या कुंजी जाँचें।", "SSH_HOST_KEY_REJECTED": "होस्ट कुंजी अस्वीकृत", "SSH_CHANNEL_ERROR": "चैनल त्रुटि", + "SSH_SHELL_UNAVAILABLE": "सर्वर इस लॉगिन के लिए इंटरैक्टिव शेल उपलब्ध नहीं कराता।", + "SSH_EXEC_UNAVAILABLE": "सर्वर इस लॉगिन के लिए कमांड चलाने की अनुमति नहीं देता।", "SSH_TIMEOUT": "सर्वर जवाब नहीं दे रहा। पता, पोर्ट और फ़ायरवॉल जाँचें, फिर दोबारा कनेक्ट करें।", "SSH_JUMP_HOST_CYCLE": "चक्रीय जंप होस्ट शृंखला मिली", "SSH_CREDENTIAL_RESOLUTION_FAILED": "क्रेडेंशियल प्राप्त करने में विफल", diff --git a/apps/smart-ssh-community/frontend/src/locales/hu/common.json b/apps/smart-ssh-community/frontend/src/locales/hu/common.json index c52f220ba..fbda2e730 100644 --- a/apps/smart-ssh-community/frontend/src/locales/hu/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/hu/common.json @@ -612,6 +612,8 @@ "SSH_AUTH_FAILED": "A bejelentkezés elutasítva. Ellenőrizze a felhasználónevet és a jelszót vagy kulcsot a szerverbeállításokban.", "SSH_HOST_KEY_REJECTED": "A gazdakulcs elutasítva", "SSH_CHANNEL_ERROR": "Csatornahiba", + "SSH_SHELL_UNAVAILABLE": "A szerver ehhez a bejelentkezéshez nem kínál interaktív shellt.", + "SSH_EXEC_UNAVAILABLE": "A szerver ehhez a bejelentkezéshez nem engedélyezi a parancsok futtatását.", "SSH_TIMEOUT": "A szerver nem válaszol. Ellenőrizze a címet, a portot és a tűzfalat, majd csatlakozzon újra.", "SSH_JUMP_HOST_CYCLE": "Körkörös ugrógép-lánc észlelve", "SSH_CREDENTIAL_RESOLUTION_FAILED": "A hitelesítő adatok feloldása sikertelen", diff --git a/apps/smart-ssh-community/frontend/src/locales/id/common.json b/apps/smart-ssh-community/frontend/src/locales/id/common.json index 08190945a..9aa9ecde8 100644 --- a/apps/smart-ssh-community/frontend/src/locales/id/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/id/common.json @@ -610,6 +610,8 @@ "SSH_AUTH_FAILED": "Login ditolak. Periksa nama pengguna dan kata sandi atau kunci di pengaturan server.", "SSH_HOST_KEY_REJECTED": "Kunci host ditolak", "SSH_CHANNEL_ERROR": "Kesalahan kanal", + "SSH_SHELL_UNAVAILABLE": "Server tidak menyediakan shell interaktif untuk login ini.", + "SSH_EXEC_UNAVAILABLE": "Server tidak mengizinkan menjalankan perintah untuk login ini.", "SSH_TIMEOUT": "Server tidak merespons. Periksa alamat, port, dan firewall, lalu hubungkan lagi.", "SSH_JUMP_HOST_CYCLE": "Rantai jump host siklik terdeteksi", "SSH_CREDENTIAL_RESOLUTION_FAILED": "Gagal menyelesaikan kredensial", diff --git a/apps/smart-ssh-community/frontend/src/locales/it/common.json b/apps/smart-ssh-community/frontend/src/locales/it/common.json index ea10426cb..464b40f76 100644 --- a/apps/smart-ssh-community/frontend/src/locales/it/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/it/common.json @@ -614,6 +614,8 @@ "SSH_AUTH_FAILED": "Accesso rifiutato. Verifichi nome utente e password o chiave nelle impostazioni del server.", "SSH_HOST_KEY_REJECTED": "Chiave host rifiutata", "SSH_CHANNEL_ERROR": "Errore del canale", + "SSH_SHELL_UNAVAILABLE": "Il server non offre una shell interattiva per questo accesso.", + "SSH_EXEC_UNAVAILABLE": "Il server non consente di eseguire comandi con questo accesso.", "SSH_TIMEOUT": "Il server non risponde. Verifichi indirizzo, porta e firewall, poi si connetta di nuovo.", "SSH_JUMP_HOST_CYCLE": "Rilevata catena ciclica di jump host", "SSH_CREDENTIAL_RESOLUTION_FAILED": "Risoluzione delle credenziali non riuscita", diff --git a/apps/smart-ssh-community/frontend/src/locales/ja/common.json b/apps/smart-ssh-community/frontend/src/locales/ja/common.json index a33dc2242..2e79065a6 100644 --- a/apps/smart-ssh-community/frontend/src/locales/ja/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/ja/common.json @@ -610,6 +610,8 @@ "SSH_AUTH_FAILED": "ログインが拒否されました。サーバー設定のユーザー名とパスワードまたは鍵を確認してください。", "SSH_HOST_KEY_REJECTED": "ホストキーが拒否されました", "SSH_CHANNEL_ERROR": "チャネルエラー", + "SSH_SHELL_UNAVAILABLE": "このログインでは、サーバーが対話型シェルを提供していません。", + "SSH_EXEC_UNAVAILABLE": "このログインでは、サーバーがコマンドの実行を許可していません。", "SSH_TIMEOUT": "サーバーが応答しません。アドレス、ポート、ファイアウォールを確認してから、もう一度接続してください。", "SSH_JUMP_HOST_CYCLE": "踏み台ホストの連鎖が循環しています", "SSH_CREDENTIAL_RESOLUTION_FAILED": "認証情報を解決できませんでした", diff --git a/apps/smart-ssh-community/frontend/src/locales/ko/common.json b/apps/smart-ssh-community/frontend/src/locales/ko/common.json index 9e2132bfe..db3931dc9 100644 --- a/apps/smart-ssh-community/frontend/src/locales/ko/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/ko/common.json @@ -610,6 +610,8 @@ "SSH_AUTH_FAILED": "로그인이 거부되었습니다. 서버 설정에서 사용자 이름과 비밀번호 또는 키를 확인하십시오.", "SSH_HOST_KEY_REJECTED": "호스트 키가 거부되었습니다", "SSH_CHANNEL_ERROR": "채널 오류", + "SSH_SHELL_UNAVAILABLE": "서버가 이 로그인에 대해 대화형 셸을 제공하지 않습니다.", + "SSH_EXEC_UNAVAILABLE": "서버가 이 로그인에 대해 명령 실행을 허용하지 않습니다.", "SSH_TIMEOUT": "서버가 응답하지 않습니다. 주소, 포트, 방화벽을 확인한 후 다시 연결하십시오.", "SSH_JUMP_HOST_CYCLE": "점프 호스트 체인이 순환합니다", "SSH_CREDENTIAL_RESOLUTION_FAILED": "자격 증명을 확인하지 못했습니다", diff --git a/apps/smart-ssh-community/frontend/src/locales/nb/common.json b/apps/smart-ssh-community/frontend/src/locales/nb/common.json index e43e612c7..9eae6564c 100644 --- a/apps/smart-ssh-community/frontend/src/locales/nb/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/nb/common.json @@ -612,6 +612,8 @@ "SSH_AUTH_FAILED": "Pålogging avvist. Sjekk brukernavn og passord eller nøkkel i serverinnstillingene.", "SSH_HOST_KEY_REJECTED": "Vertsnøkkel avvist", "SSH_CHANNEL_ERROR": "Kanalfeil", + "SSH_SHELL_UNAVAILABLE": "Serveren tilbyr ikke et interaktivt skall for denne innloggingen.", + "SSH_EXEC_UNAVAILABLE": "Serveren tillater ikke å kjøre kommandoer for denne innloggingen.", "SSH_TIMEOUT": "Serveren svarer ikke. Sjekk adresse, port og brannmur, og koble til på nytt.", "SSH_JUMP_HOST_CYCLE": "Syklisk kjede av hoppverter oppdaget", "SSH_CREDENTIAL_RESOLUTION_FAILED": "Kunne ikke finne legitimasjonen", diff --git a/apps/smart-ssh-community/frontend/src/locales/nl/common.json b/apps/smart-ssh-community/frontend/src/locales/nl/common.json index 32ff46449..cef8a4a62 100644 --- a/apps/smart-ssh-community/frontend/src/locales/nl/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/nl/common.json @@ -612,6 +612,8 @@ "SSH_AUTH_FAILED": "Aanmelding geweigerd. Controleer de gebruikersnaam en het wachtwoord of de sleutel in de serverinstellingen.", "SSH_HOST_KEY_REJECTED": "Hostsleutel geweigerd", "SSH_CHANNEL_ERROR": "Kanaalfout", + "SSH_SHELL_UNAVAILABLE": "De server biedt voor deze aanmelding geen interactieve shell aan.", + "SSH_EXEC_UNAVAILABLE": "De server staat voor deze aanmelding het uitvoeren van opdrachten niet toe.", "SSH_TIMEOUT": "De server reageert niet. Controleer adres, poort en firewall en verbind opnieuw.", "SSH_JUMP_HOST_CYCLE": "Cyclische jumphost-keten gedetecteerd", "SSH_CREDENTIAL_RESOLUTION_FAILED": "Inloggegevens ophalen mislukt", diff --git a/apps/smart-ssh-community/frontend/src/locales/pl/common.json b/apps/smart-ssh-community/frontend/src/locales/pl/common.json index ceda87bb9..f4866bea6 100644 --- a/apps/smart-ssh-community/frontend/src/locales/pl/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/pl/common.json @@ -616,6 +616,8 @@ "SSH_AUTH_FAILED": "Logowanie odrzucone. Sprawdź nazwę użytkownika oraz hasło lub klucz w ustawieniach serwera.", "SSH_HOST_KEY_REJECTED": "Klucz hosta odrzucony", "SSH_CHANNEL_ERROR": "Błąd kanału", + "SSH_SHELL_UNAVAILABLE": "Serwer nie udostępnia interaktywnej powłoki dla tego logowania.", + "SSH_EXEC_UNAVAILABLE": "Serwer nie zezwala na uruchamianie poleceń dla tego logowania.", "SSH_TIMEOUT": "Serwer nie odpowiada. Sprawdź adres, port i zaporę, a potem połącz się ponownie.", "SSH_JUMP_HOST_CYCLE": "Wykryto cykliczny łańcuch hostów pośredniczących", "SSH_CREDENTIAL_RESOLUTION_FAILED": "Nie udało się ustalić danych uwierzytelniających", diff --git a/apps/smart-ssh-community/frontend/src/locales/pt-BR/common.json b/apps/smart-ssh-community/frontend/src/locales/pt-BR/common.json index 1ce3a05e6..ae62e044e 100644 --- a/apps/smart-ssh-community/frontend/src/locales/pt-BR/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/pt-BR/common.json @@ -614,6 +614,8 @@ "SSH_AUTH_FAILED": "Login recusado. Verifique o nome de usuário e a senha ou chave nas configurações do servidor.", "SSH_HOST_KEY_REJECTED": "Chave de host rejeitada", "SSH_CHANNEL_ERROR": "Erro de canal", + "SSH_SHELL_UNAVAILABLE": "O servidor não oferece um shell interativo para este login.", + "SSH_EXEC_UNAVAILABLE": "O servidor não permite executar comandos com este login.", "SSH_TIMEOUT": "O servidor não está respondendo. Verifique o endereço, a porta e o firewall e conecte novamente.", "SSH_JUMP_HOST_CYCLE": "Cadeia cíclica de hosts de salto detectada", "SSH_CREDENTIAL_RESOLUTION_FAILED": "Falha ao resolver as credenciais", diff --git a/apps/smart-ssh-community/frontend/src/locales/ro/common.json b/apps/smart-ssh-community/frontend/src/locales/ro/common.json index 0047ef6bd..16967b6dd 100644 --- a/apps/smart-ssh-community/frontend/src/locales/ro/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/ro/common.json @@ -614,6 +614,8 @@ "SSH_AUTH_FAILED": "Autentificare respinsă. Verificați numele de utilizator și parola sau cheia în setările serverului.", "SSH_HOST_KEY_REJECTED": "Cheia de host respinsă", "SSH_CHANNEL_ERROR": "Eroare de canal", + "SSH_SHELL_UNAVAILABLE": "Serverul nu oferă un shell interactiv pentru această autentificare.", + "SSH_EXEC_UNAVAILABLE": "Serverul nu permite rularea de comenzi pentru această autentificare.", "SSH_TIMEOUT": "Serverul nu răspunde. Verificați adresa, portul și firewall-ul, apoi conectați-vă din nou.", "SSH_JUMP_HOST_CYCLE": "Lanț ciclic de jump host detectat", "SSH_CREDENTIAL_RESOLUTION_FAILED": "Datele de autentificare nu au putut fi rezolvate", diff --git a/apps/smart-ssh-community/frontend/src/locales/ru/common.json b/apps/smart-ssh-community/frontend/src/locales/ru/common.json index b1f9da34b..5d183239a 100644 --- a/apps/smart-ssh-community/frontend/src/locales/ru/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/ru/common.json @@ -616,6 +616,8 @@ "SSH_AUTH_FAILED": "Вход отклонён. Проверьте имя пользователя и пароль или ключ в настройках сервера.", "SSH_HOST_KEY_REJECTED": "Ключ хоста отклонён", "SSH_CHANNEL_ERROR": "Ошибка канала", + "SSH_SHELL_UNAVAILABLE": "Сервер не предоставляет интерактивную оболочку для этого входа.", + "SSH_EXEC_UNAVAILABLE": "Сервер не разрешает выполнять команды для этого входа.", "SSH_TIMEOUT": "Сервер не отвечает. Проверьте адрес, порт и брандмауэр, затем подключитесь снова.", "SSH_JUMP_HOST_CYCLE": "Обнаружена циклическая цепочка промежуточных хостов", "SSH_CREDENTIAL_RESOLUTION_FAILED": "Не удалось получить учётные данные", diff --git a/apps/smart-ssh-community/frontend/src/locales/sv/common.json b/apps/smart-ssh-community/frontend/src/locales/sv/common.json index 691f2e279..b979001f4 100644 --- a/apps/smart-ssh-community/frontend/src/locales/sv/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/sv/common.json @@ -612,6 +612,8 @@ "SSH_AUTH_FAILED": "Inloggningen avvisades. Kontrollera användarnamn och lösenord eller nyckel i serverinställningarna.", "SSH_HOST_KEY_REJECTED": "Värdnyckeln avvisades", "SSH_CHANNEL_ERROR": "Kanalfel", + "SSH_SHELL_UNAVAILABLE": "Servern erbjuder inget interaktivt skal för den här inloggningen.", + "SSH_EXEC_UNAVAILABLE": "Servern tillåter inte att köra kommandon för den här inloggningen.", "SSH_TIMEOUT": "Servern svarar inte. Kontrollera adress, port och brandvägg och anslut sedan igen.", "SSH_JUMP_HOST_CYCLE": "Cirkulär hoppvärdskedja upptäcktes", "SSH_CREDENTIAL_RESOLUTION_FAILED": "Det gick inte att lösa upp inloggningsuppgifterna", diff --git a/apps/smart-ssh-community/frontend/src/locales/tr/common.json b/apps/smart-ssh-community/frontend/src/locales/tr/common.json index 82a70ff5e..01b90d1a4 100644 --- a/apps/smart-ssh-community/frontend/src/locales/tr/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/tr/common.json @@ -612,6 +612,8 @@ "SSH_AUTH_FAILED": "Oturum açma reddedildi. Sunucu ayarlarında kullanıcı adını ve parolayı ya da anahtarı denetleyin.", "SSH_HOST_KEY_REJECTED": "Ana makine anahtarı reddedildi", "SSH_CHANNEL_ERROR": "Kanal hatası", + "SSH_SHELL_UNAVAILABLE": "Sunucu bu oturum için etkileşimli bir kabuk sunmuyor.", + "SSH_EXEC_UNAVAILABLE": "Sunucu bu oturum için komut çalıştırmaya izin vermiyor.", "SSH_TIMEOUT": "Sunucu yanıt vermiyor. Adresi, bağlantı noktasını ve güvenlik duvarını denetleyin, sonra yeniden bağlanın.", "SSH_JUMP_HOST_CYCLE": "Döngüsel atlama sunucusu zinciri algılandı", "SSH_CREDENTIAL_RESOLUTION_FAILED": "Kimlik bilgileri çözümlenemedi", diff --git a/apps/smart-ssh-community/frontend/src/locales/uk/common.json b/apps/smart-ssh-community/frontend/src/locales/uk/common.json index 144fefa67..b36e1d91f 100644 --- a/apps/smart-ssh-community/frontend/src/locales/uk/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/uk/common.json @@ -616,6 +616,8 @@ "SSH_AUTH_FAILED": "Вхід відхилено. Перевірте ім'я користувача та пароль або ключ у параметрах сервера.", "SSH_HOST_KEY_REJECTED": "Ключ хоста відхилено", "SSH_CHANNEL_ERROR": "Помилка каналу", + "SSH_SHELL_UNAVAILABLE": "Сервер не надає інтерактивну оболонку для цього входу.", + "SSH_EXEC_UNAVAILABLE": "Сервер не дозволяє виконувати команди для цього входу.", "SSH_TIMEOUT": "Сервер не відповідає. Перевірте адресу, порт і брандмауер, потім підключіться знову.", "SSH_JUMP_HOST_CYCLE": "Виявлено циклічний ланцюжок проміжних хостів", "SSH_CREDENTIAL_RESOLUTION_FAILED": "Не вдалося визначити облікові дані", diff --git a/apps/smart-ssh-community/frontend/src/locales/vi/common.json b/apps/smart-ssh-community/frontend/src/locales/vi/common.json index 65aa456de..ba1ccf067 100644 --- a/apps/smart-ssh-community/frontend/src/locales/vi/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/vi/common.json @@ -610,6 +610,8 @@ "SSH_AUTH_FAILED": "Đăng nhập bị từ chối. Kiểm tra tên người dùng và mật khẩu hoặc khóa trong cài đặt máy chủ.", "SSH_HOST_KEY_REJECTED": "Khóa máy chủ bị từ chối", "SSH_CHANNEL_ERROR": "Lỗi kênh", + "SSH_SHELL_UNAVAILABLE": "Máy chủ không cung cấp shell tương tác cho lần đăng nhập này.", + "SSH_EXEC_UNAVAILABLE": "Máy chủ không cho phép chạy lệnh với lần đăng nhập này.", "SSH_TIMEOUT": "Máy chủ không phản hồi. Kiểm tra địa chỉ, cổng và tường lửa, rồi kết nối lại.", "SSH_JUMP_HOST_CYCLE": "Phát hiện chuỗi máy chủ trung chuyển lặp vòng", "SSH_CREDENTIAL_RESOLUTION_FAILED": "Không thể xác định thông tin xác thực", diff --git a/apps/smart-ssh-community/frontend/src/locales/zh-Hans/common.json b/apps/smart-ssh-community/frontend/src/locales/zh-Hans/common.json index cc013cac0..5650b2106 100644 --- a/apps/smart-ssh-community/frontend/src/locales/zh-Hans/common.json +++ b/apps/smart-ssh-community/frontend/src/locales/zh-Hans/common.json @@ -610,6 +610,8 @@ "SSH_AUTH_FAILED": "登录被拒绝。请在服务器设置中检查用户名以及密码或密钥。", "SSH_HOST_KEY_REJECTED": "主机密钥已被拒绝", "SSH_CHANNEL_ERROR": "通道错误", + "SSH_SHELL_UNAVAILABLE": "服务器不为此登录提供交互式 shell。", + "SSH_EXEC_UNAVAILABLE": "服务器不允许此登录运行命令。", "SSH_TIMEOUT": "服务器没有响应。请检查地址、端口和防火墙,然后重新连接。", "SSH_JUMP_HOST_CYCLE": "检测到跳板机链存在循环", "SSH_CREDENTIAL_RESOLUTION_FAILED": "无法解析凭据", diff --git a/changelog.d/issue-1665-refused-shell-and-exec.md b/changelog.d/issue-1665-refused-shell-and-exec.md new file mode 100644 index 000000000..bce522c37 --- /dev/null +++ b/changelog.d/issue-1665-refused-shell-and-exec.md @@ -0,0 +1,2 @@ +### Fixed +- A server that refuses a shell or command request, or that forces SFTP on every channel, now fails within seconds with a clear message instead of hanging. diff --git a/crates/app-logic/src/auto_reconnect.rs b/crates/app-logic/src/auto_reconnect.rs index a86132fdf..61476a99d 100644 --- a/crates/app-logic/src/auto_reconnect.rs +++ b/crates/app-logic/src/auto_reconnect.rs @@ -334,6 +334,9 @@ mod tests { "SSH_HOST_KEY_REJECTED", "SECRET_STORE_FAILED", "SSH_CREDENTIAL_RESOLUTION_FAILED", + // Issue #1665: a server that refuses shell/exec will refuse again. + "SSH_SHELL_UNAVAILABLE", + "SSH_EXEC_UNAVAILABLE", "SOMETHING_NEW", ] { assert!(!is_retryable_code(Some(code)), "{code}"); diff --git a/crates/core/src/ssh/error.rs b/crates/core/src/ssh/error.rs index 7cb8003f1..242758745 100644 --- a/crates/core/src/ssh/error.rs +++ b/crates/core/src/ssh/error.rs @@ -92,6 +92,11 @@ pub enum SshError { }, HostKeyRejected, ChannelError(String), + /// Issue #1665: the server refused the shell request (e.g. a + /// `ForceCommand`/restricted account that allows no interactive shell). + ShellUnavailable(String), + /// Issue #1665: the server refused the exec request. + ExecUnavailable(String), Timeout, JumpHostCycle, CredentialResolutionFailed(String), @@ -193,6 +198,10 @@ impl fmt::Display for SshError { ), SshError::HostKeyRejected => write!(f, "Host-Key abgelehnt"), SshError::ChannelError(msg) => write!(f, "Channel-Fehler: {msg}"), + SshError::ShellUnavailable(msg) => write!(f, "Shell nicht verfügbar: {msg}"), + SshError::ExecUnavailable(msg) => { + write!(f, "Befehlsausführung nicht verfügbar: {msg}") + } SshError::Timeout => write!(f, "Zeitüberschreitung"), SshError::JumpHostCycle => write!(f, "zyklische Jump-Host-Kette erkannt"), SshError::CredentialResolutionFailed(msg) => { @@ -267,6 +276,8 @@ impl SshError { "SSH_AUTH_FAILED", "SSH_HOST_KEY_REJECTED", "SSH_CHANNEL_ERROR", + "SSH_SHELL_UNAVAILABLE", + "SSH_EXEC_UNAVAILABLE", "SSH_TIMEOUT", "SSH_JUMP_HOST_CYCLE", "SSH_CREDENTIAL_RESOLUTION_FAILED", @@ -295,6 +306,8 @@ impl SshError { } SshError::HostKeyRejected => "SSH_HOST_KEY_REJECTED", SshError::ChannelError(_) => "SSH_CHANNEL_ERROR", + SshError::ShellUnavailable(_) => "SSH_SHELL_UNAVAILABLE", + SshError::ExecUnavailable(_) => "SSH_EXEC_UNAVAILABLE", SshError::Timeout => "SSH_TIMEOUT", SshError::JumpHostCycle => "SSH_JUMP_HOST_CYCLE", SshError::CredentialResolutionFailed(_) => "SSH_CREDENTIAL_RESOLUTION_FAILED", @@ -397,6 +410,9 @@ mod code_tests { SshError::AuthenticationFailed, SshError::HostKeyRejected, SshError::ChannelError("x".to_string()), + // Issue #1665. + SshError::ShellUnavailable("x".to_string()), + SshError::ExecUnavailable("x".to_string()), SshError::Timeout, SshError::JumpHostCycle, SshError::CredentialResolutionFailed("x".to_string()), diff --git a/crates/ssh-transport/src/transport.rs b/crates/ssh-transport/src/transport.rs index 7f5432fe3..555578371 100644 --- a/crates/ssh-transport/src/transport.rs +++ b/crates/ssh-transport/src/transport.rs @@ -136,6 +136,49 @@ async fn drain_channel_cancellable( }) } +/// Outcome of waiting for the server's reply to a channel request. +#[derive(Debug, PartialEq, Eq)] +enum RequestReply { + Accepted, + Refused, + /// `Close`/`Eof` or the end of the channel came before any reply. + Closed, +} + +/// Issue #1665: waits for `Success`/`Failure` to a request sent with +/// `want_reply`; other messages are skipped (`None` = channel gone). +async fn wait_for_request_reply(source: &mut impl ReplySource) -> RequestReply { + loop { + match source.next_msg().await { + Some(ChannelMsg::Success) => return RequestReply::Accepted, + Some(ChannelMsg::Failure) => return RequestReply::Refused, + Some(ChannelMsg::Close | ChannelMsg::Eof) | None => return RequestReply::Closed, + Some(_) => continue, + } + } +} + +/// Source of channel messages for [`wait_for_request_reply`]; a seam so the +/// reply handling is testable without a server. +#[async_trait] +trait ReplySource: Send { + async fn next_msg(&mut self) -> Option; +} + +#[async_trait] +impl ReplySource for Channel { + async fn next_msg(&mut self) -> Option { + self.wait().await + } +} + +fn exec_refused_error() -> SshError { + SshError::ExecUnavailable( + "Der Server hat die Befehlsausführung abgelehnt (The server refused the exec request)" + .to_string(), + ) +} + /// Issue #328: an exec channel that outlives the transport lock. struct RunningRusshExec { channel: Channel, @@ -267,6 +310,24 @@ impl SshTransport for RusshTransport { .request_shell(true) .await .map_err(map_session_russh_error)?; + // Issue #1665: wait for the reply to the shell request; a refusal + // would otherwise surface only as a skipped `Failure` message and a + // terminal that never shows anything. + match wait_for_request_reply(&mut channel).await { + RequestReply::Accepted => {} + RequestReply::Refused => { + let _ = channel.close().await; + return Err(SshError::ShellUnavailable( + "Der Server hat die Shell-Anfrage abgelehnt (The server refused the shell request)" + .to_string(), + )); + } + RequestReply::Closed => { + return Err(SshError::SessionClosed( + "Verbindung während der Shell-Anfrage geschlossen".to_string(), + )); + } + } Ok(Box::new(RusshShell { channel })) } @@ -394,7 +455,28 @@ impl RusshTransport { command: &str, stdin: Option<&[u8]>, ) -> Result, SshError> { - let channel = self + self.open_exec_channel(command, stdin, true).await + } + + /// Like [`Self::open_exec`], but without stdin the channel stays open + /// for writing (no EOF). For callers that talk to the process later + /// (sudo password prompt, SFTP over exec). + async fn open_exec_interactive(&self, command: &str) -> Result, SshError> { + self.open_exec_channel(command, None, false).await + } + + /// Issue #1665: waits for the server's reply to the exec request. A + /// refusal fails with `ExecUnavailable`; without stdin and with + /// `eof_without_stdin` the channel gets EOF right after the request was + /// accepted (like `ssh host cmd , + eof_without_stdin: bool, + ) -> Result, SshError> { + let mut channel = self .handle .channel_open_session() .await @@ -403,14 +485,33 @@ impl RusshTransport { .exec(true, command) .await .map_err(map_session_russh_error)?; - if let Some(stdin) = stdin { - if !stdin.is_empty() { - channel - .data_bytes(stdin.to_vec()) - .await - .map_err(map_session_russh_error)?; + match wait_for_request_reply(&mut channel).await { + RequestReply::Accepted => {} + RequestReply::Refused => { + // Best effort: the channel is useless either way. + let _ = channel.close().await; + return Err(exec_refused_error()); + } + RequestReply::Closed => { + return Err(SshError::SessionClosed( + "Verbindung während der Exec-Anfrage geschlossen".to_string(), + )); } - channel.eof().await.map_err(map_session_russh_error)?; + } + match stdin { + Some(stdin) => { + if !stdin.is_empty() { + channel + .data_bytes(stdin.to_vec()) + .await + .map_err(map_session_russh_error)?; + } + channel.eof().await.map_err(map_session_russh_error)?; + } + None if eof_without_stdin => { + channel.eof().await.map_err(map_session_russh_error)?; + } + None => {} } Ok(channel) } @@ -424,7 +525,7 @@ impl RusshTransport { ) -> Result, SudoPromptError> { use crate::sudo_prompt::{wait_for_marker, StderrWatch}; let mut channel = self - .open_exec(command, None) + .open_exec_interactive(command) .await .map_err(SudoPromptError::Failed)?; let mut watch = StderrWatch::new(marker); @@ -479,7 +580,7 @@ impl RusshTransport { &mut self, command: &str, ) -> Result, SshError> { - let channel = self.open_exec(command, None).await?; + let channel = self.open_exec_interactive(command).await?; // `russh-sftp` wartet auf jede Antwort bis zum Request-Timeout // (Default 10 s) — auch dann, wenn der Kanal schon zu ist (sudo hat // abgelehnt). Für den Handshake daher kurz, danach der Normalwert. @@ -505,3 +606,54 @@ impl RusshTransport { ))) } } + +#[cfg(test)] +mod request_reply_tests { + use super::*; + use std::collections::VecDeque; + + async fn reply_to(msgs: Vec>) -> RequestReply { + struct Scripted(VecDeque>); + #[async_trait] + impl ReplySource for Scripted { + async fn next_msg(&mut self) -> Option { + self.0.pop_front().flatten() + } + } + wait_for_request_reply(&mut Scripted(msgs.into())).await + } + + #[tokio::test] + async fn test_failure_reply_is_refused() { + assert_eq!( + reply_to(vec![Some(ChannelMsg::Failure)]).await, + RequestReply::Refused + ); + } + + #[tokio::test] + async fn test_success_reply_after_unrelated_messages_is_accepted() { + let r = reply_to(vec![ + Some(ChannelMsg::WindowAdjusted { new_size: 1 }), + Some(ChannelMsg::Success), + ]) + .await; + assert_eq!(r, RequestReply::Accepted); + } + + #[tokio::test] + async fn test_close_eof_or_end_before_reply_is_closed() { + for m in [Some(ChannelMsg::Close), Some(ChannelMsg::Eof), None] { + assert_eq!(reply_to(vec![m]).await, RequestReply::Closed); + } + } + + #[test] + fn test_refused_requests_map_to_the_new_codes() { + assert_eq!(exec_refused_error().code(), "SSH_EXEC_UNAVAILABLE"); + assert_eq!( + SshError::ShellUnavailable("x".into()).code(), + "SSH_SHELL_UNAVAILABLE" + ); + } +} diff --git a/crates/ssh-transport/tests/fixtures/test_server.rs b/crates/ssh-transport/tests/fixtures/test_server.rs index e9d225606..7c06bf6f8 100644 --- a/crates/ssh-transport/tests/fixtures/test_server.rs +++ b/crates/ssh-transport/tests/fixtures/test_server.rs @@ -265,6 +265,9 @@ impl AuthAttemptLog { /// Läuft ein `RunningTestServer` und stoppt ihn beim Droppen (best effort — /// der Shutdown-Kanal wird geschlossen, der Accept-Loop-Task beendet sich /// dadurch spätestens beim nächsten `select!`-Durchlauf). +/// PTY width that makes the test server refuse the following shell request. +pub const REFUSE_SHELL_COLS: u32 = 13; + pub struct RunningTestServer { pub addr: SocketAddr, /// Roh-Bytes des Host-Public-Keys, den dieser Server präsentiert — für @@ -392,6 +395,7 @@ impl RunningTestServer { let handler = TestHandler { channels: HashMap::new(), no_echo: HashSet::new(), + refuse_shell: HashSet::new(), sftp_root, exec_channel, sudo_stdin, @@ -447,6 +451,9 @@ struct TestHandler { /// Kanäle nicht laufen, sonst landet jeder Client-Schreibvorgang als /// Fremddaten wieder im Stream und erschöpft das Kanalfenster (#179). no_echo: HashSet, + /// Issue #1665: channels whose shell request is refused (PTY width + /// [`REFUSE_SHELL_COLS`]). + refuse_shell: HashSet, sftp_root: PathBuf, /// Spec 0085, A2.1/T14: bekommt nur das SFTP-Subsystem des über `exec` /// geöffneten Kanals mit — das normale `sftp`-Subsystem soll den Zähler @@ -702,6 +709,14 @@ impl Handler for TestHandler { }); return Ok(()); } + // Issue #1665: a server that refuses the exec request. + if command == "refused-exec" { + session.channel_failure(channel)?; + return Ok(()); + } + // Issue #1665: like every real server, accept the request before any + // output; the client waits for this reply. + session.channel_success(channel)?; // Spec 0067, Teil A: sudo verweigert ohne Passwort — Meldung nur auf // stderr, dann Ende. Der Client darf dabei nie hängen. if command == "sudo -n /denied/sftp-server" { @@ -766,13 +781,16 @@ impl Handler for TestHandler { &mut self, channel: ChannelId, _term: &str, - _col_width: u32, + col_width: u32, _row_height: u32, _pix_width: u32, _pix_height: u32, _modes: &[(Pty, u32)], session: &mut Session, ) -> Result<(), Self::Error> { + if col_width == REFUSE_SHELL_COLS { + self.refuse_shell.insert(channel); + } session.channel_success(channel)?; Ok(()) } @@ -782,6 +800,10 @@ impl Handler for TestHandler { channel: ChannelId, session: &mut Session, ) -> Result<(), Self::Error> { + if self.refuse_shell.contains(&channel) { + session.channel_failure(channel)?; + return Ok(()); + } session.channel_success(channel)?; Ok(()) } diff --git a/crates/ssh-transport/tests/sshd/scenarios/io-sftponly/scenario.toml b/crates/ssh-transport/tests/sshd/scenarios/io-sftponly/scenario.toml new file mode 100644 index 000000000..b25ae4811 --- /dev/null +++ b/crates/ssh-transport/tests/sshd/scenarios/io-sftponly/scenario.toml @@ -0,0 +1,4 @@ +image = "openssh-current" +hostname = "io-sftponly" +networks = ["io-net"] +publish = true diff --git a/crates/ssh-transport/tests/sshd/scenarios/io-sftponly/setup.sh b/crates/ssh-transport/tests/sshd/scenarios/io-sftponly/setup.sh new file mode 100644 index 000000000..bcf089eb7 --- /dev/null +++ b/crates/ssh-transport/tests/sshd/scenarios/io-sftponly/setup.sh @@ -0,0 +1,8 @@ +# Runs as root before the daemon: a root-owned chroot directory (sshd +# requires every component to be root-owned and not group/world-writable). +set -eu +root=/srv/sftp-root +mkdir -p "$root/home/testuser" +echo chroot > "$root/marker.txt" +chown -R root:root "$root" +chmod 755 "$root" "$root/home" "$root/home/testuser" diff --git a/crates/ssh-transport/tests/sshd/scenarios/io-sftponly/sshd_config b/crates/ssh-transport/tests/sshd/scenarios/io-sftponly/sshd_config new file mode 100644 index 000000000..1c808f8ce --- /dev/null +++ b/crates/ssh-transport/tests/sshd/scenarios/io-sftponly/sshd_config @@ -0,0 +1,9 @@ +PasswordAuthentication yes +KbdInteractiveAuthentication no +PermitRootLogin no +LogLevel VERBOSE +# Every channel runs internal-sftp inside the chroot: exec and shell requests +# start an sftp server that waits for SFTP on stdin (issue #1665). +Subsystem sftp internal-sftp +ForceCommand internal-sftp +ChrootDirectory /srv/sftp-root diff --git a/crates/ssh-transport/tests/sshd_sftp_only.rs b/crates/ssh-transport/tests/sshd_sftp_only.rs new file mode 100644 index 000000000..035a6bf1e --- /dev/null +++ b/crates/ssh-transport/tests/sshd_sftp_only.rs @@ -0,0 +1,75 @@ +//! Servers that force SFTP on every channel, and exec without stdin (issue +//! #1665): `execute` and `open_shell` fail or end fast instead of hanging. +//! Scenario `io-sftponly` (OpenSSH, `ForceCommand internal-sftp` in a chroot). +//! Run through `tests/sshd/run.sh`. + +mod sshd_support; + +use ssh_manager_core::ssh::{PtySize, SshError}; +use sshd_support::{connect_scenario, step}; +use std::time::{Duration, Instant}; + +const WITHIN: Duration = Duration::from_secs(5); + +#[ignore = "needs sshd containers, see tests/sshd/README.md"] +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn execute_against_forced_sftp_returns_without_hanging_and_without_running_the_command() { + let mut t = connect_scenario("io-sftponly").await; + let started = Instant::now(); + let out = step("execute(uname -a)", t.execute("uname -a")) + .await + .unwrap(); + assert!(started.elapsed() < WITHIN, "took {:?}", started.elapsed()); + // The forced `internal-sftp` never runs `uname`; it ends on EOF, or (as + // OpenSSH does for a non-SFTP request) prints its own refusal notice. + let text = String::from_utf8_lossy(&out.stdout); + assert!( + text.is_empty() || text.contains("sftp connections only"), + "stdout: {text:?}" + ); +} + +#[ignore = "needs sshd containers, see tests/sshd/README.md"] +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn open_shell_against_forced_sftp_fails_or_reports_session_closed() { + let mut t = connect_scenario("io-sftponly").await; + let started = Instant::now(); + let res = tokio::time::timeout(WITHIN, async { + let mut shell = t.open_shell(PtySize { cols: 80, rows: 24 }).await?; + // A shell that did open must end (empty read = closed), not hang. + loop { + if shell.read().await?.is_empty() { + return Ok::<(), SshError>(()); + } + } + }) + .await; + assert!( + res.is_ok(), + "open_shell/read hung for {:?}", + started.elapsed() + ); +} + +#[ignore = "needs sshd containers, see tests/sshd/README.md"] +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn open_sftp_against_forced_sftp_lists_the_chroot_root() { + let mut t = connect_scenario("io-sftponly").await; + let mut sftp = step("open_sftp", t.open_sftp()).await.unwrap(); + let entries = step("list_dir(/)", sftp.list_dir("/")).await.unwrap(); + assert!( + entries.iter().any(|e| e.name == "marker.txt"), + "entries: {entries:?}" + ); +} + +#[ignore = "needs sshd containers, see tests/sshd/README.md"] +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn exec_without_stdin_of_cat_exits_zero() { + let mut t = connect_scenario("io-basic").await; + let started = Instant::now(); + let out = step("execute(cat)", t.execute("cat")).await.unwrap(); + assert!(started.elapsed() < WITHIN, "took {:?}", started.elapsed()); + assert_eq!(out.exit_code, Some(0)); + assert!(out.stdout.is_empty()); +} diff --git a/crates/ssh-transport/tests/sudo_password.rs b/crates/ssh-transport/tests/sudo_password.rs index 58554a042..57dd84639 100644 --- a/crates/ssh-transport/tests/sudo_password.rs +++ b/crates/ssh-transport/tests/sudo_password.rs @@ -187,3 +187,38 @@ async fn test_sudo_password_path_not_allowed() { assert!(matches!(err, SudoPromptError::NotAllowed(_)), "{err:?}"); assert!(server.sudo_stdin.lock().unwrap().is_empty()); } + +/// Issue #1665: a refused exec request fails with `SSH_EXEC_UNAVAILABLE` +/// right away instead of waiting for the channel to end. +#[tokio::test] +async fn test_refused_exec_request_is_exec_unavailable() { + let server = RunningTestServer::start().await; + let mut transport = connect_trusted(&server).await; + let res = tokio::time::timeout( + std::time::Duration::from_secs(5), + transport.execute("refused-exec"), + ) + .await + .expect("a refused exec must not hang"); + let err = res.expect_err("refused exec must fail"); + assert_eq!(err.code(), "SSH_EXEC_UNAVAILABLE", "{err:?}"); +} + +/// Issue #1665: a refused shell request fails `open_shell` with +/// `SSH_SHELL_UNAVAILABLE` right away. +#[tokio::test] +async fn test_refused_shell_request_is_shell_unavailable() { + let server = RunningTestServer::start().await; + let mut transport = connect_trusted(&server).await; + let res = tokio::time::timeout( + std::time::Duration::from_secs(5), + transport.open_shell(ssh_manager_core::ssh::PtySize { + cols: fixtures::test_server::REFUSE_SHELL_COLS as u16, + rows: 24, + }), + ) + .await + .expect("a refused shell must not hang"); + let err = res.err().expect("refused shell must fail"); + assert_eq!(err.code(), "SSH_SHELL_UNAVAILABLE", "{err:?}"); +} diff --git a/docs/specs/0005-ssh-module.md b/docs/specs/0005-ssh-module.md index c20dadacc..f7203b02d 100644 --- a/docs/specs/0005-ssh-module.md +++ b/docs/specs/0005-ssh-module.md @@ -47,7 +47,12 @@ anmelden, die nur der Zertifizierungsstelle vertrauen. **4.1 Einzelkommando.** Ergebnis ist Standardausgabe, Fehlerausgabe und der Exit-Code. Beendet sich der Kanal ohne Exit-Code (etwa nach einem Abbruch, -Spec 0027), bleibt der Exit-Code leer; das ist kein Fehler. +Spec 0027), bleibt der Exit-Code leer; das ist kein Fehler. Der Server +bestätigt oder lehnt den Start des Kommandos ab; eine Ablehnung scheitert sofort +mit „Befehlsausführung nicht verfügbar“, ohne zu warten. Ein Kommando ohne +Eingabedaten bekommt gleich nach der Bestätigung das Ende der Standardeingabe +(wie `ssh host cmd