Précédent   Forum des professionnels en informatique > Systèmes > Linux > Réseau
Réseau Vos questions autour des réseaux et télécoms sous Linux
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 21/11/2006, 11h07   #1
Invité régulier
 
Inscription : novembre 2006
Messages : 32
Détails du profil
Informations forums :
Inscription : novembre 2006
Messages : 32
Points : 9
Points : 9
Par défaut Exécution du .profile impossible par SSH

Bonjour,

Je développe une application en java exécutant du code à distance. Le protocole utilisé est SSH et la librairie java utilisé est SSHtools.

Je souhaiterais exécuter le fichier .profile pour récupérer les variables d'environnement d'utilisateurs (car il ne s'exécute pas par défaut au démarrage de la session).

Lorsque je l'exécute sur une machine, cela ne pose pas de problème, mais lorsque j'essaye sur une autre j'obtiens le message d'erreur Not a terminal. Je pense donc que ça vient de la configuration du serveur SSH mais je ne vois pas l'option qui pourrait résoudre ce problème.

Voici le fichier de configuration sshd_conf
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
 
#       $OpenBSD: sshd_config,v 1.59 2002/09/25 11:17:16 markus 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:/system/product
s/openssh/bin
 
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options change a
# default value.
 
Port 22
Protocol 2
#ListenAddress 0.0.0.0
#ListenAddress ::
 
# HostKey for protocol version 1
#HostKey /system/products/openssh/conf/ssh_host_key
# HostKeys for protocol version 2
HostKey /system/products/openssh/conf/ssh_host_rsa_key
HostKey /system/products/openssh/conf/ssh_host_dsa_key
 
# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 3600
#ServerKeyBits 768
 
# Logging
#obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
LogLevel INFO
 
# Authentication:
 
LoginGraceTime 60
PermitRootLogin no
StrictModes yes
 
#RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile     .ssh/authorized_keys
 
# rhosts authentication should not be used (Deprecated option)
#RhostsAuthentication no
# Don't read the user's ~/.rhosts and ~/.shosts files
...skipping...
 
# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 3600
#ServerKeyBits 768
 
# Logging
#obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
LogLevel INFO
 
# Authentication:
 
LoginGraceTime 60
PermitRootLogin no
StrictModes yes
 
#RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile     .ssh/authorized_keys
 
# rhosts authentication should not be used (Deprecated option)
#RhostsAuthentication no
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /system/products/openssh/conf/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
IgnoreUserKnownHosts yes
 
# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
#PermitEmptyPasswords no
 
# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
 
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
 
#AFSTokenPassing no
 
# Kerberos TGT Passing only works with the AFS kaserver
#KerberosTgtPassing no
 
# Set this to 'yes' to enable PAM keyboard-interactive authentication
# Warning: enabling this may bypass the setting of 'PasswordAuthentication'
#PAMAuthenticationViaKbdInt no
 
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
PrintMotd no
PrintLastLog yes
KeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
Compression no
 
#MaxStartups 10
# no default banner path
Banner /system/products/openssh/conf/banner.txt
#VerifyReverseMapping no
 
# override default of no subsystems
Subsystem       sftp    /system/products/openssh/libexec/sftp-server
Est ce que le problème vient bien de ce fichier ou est autre chose qui pose problème?

Merci pour vos réponses
djanggawul est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/11/2006, 13h54   #2
Expert Confirmé
 
Avatar de Katyucha
 
Inscription : mars 2004
Messages : 3 109
Détails du profil
Informations personnelles :
Âge : 31
Localisation : Allemagne

Informations forums :
Inscription : mars 2004
Messages : 3 109
Points : 3 313
Points : 3 313
comment l'excutes tu ?
__________________
Ancien Rédacteur Linux && Unix / Nouveau retraité de DVP
The UNIX way of sex:
gunzip;strip;touch;finger;mount;fsck;more;yes;umount;sleep

Je ne réponds ni aux messages privées, ni aux messages plein de fautes...
Katyucha est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/11/2006, 14h08   #3
Invité régulier
 
Inscription : novembre 2006
Messages : 32
Détails du profil
Informations forums :
Inscription : novembre 2006
Messages : 32
Points : 9
Points : 9
Citation:
Envoyé par Katyucha
comment l'excutes tu ?
Je fais appel à une classe java qui encapsule la classe com.sshtools.j2ssh.SshClient. Ma classe transmets sans modification la commande à la classe encapsulée.

Voici le code effectuer lors de mon test unitaire
Code :
1
2
3
4
5
6
7
8
9
10
11
 
Shell ssh = new Ssh();
String sortie = null;
 
try {
   sortie = ssh.exec(POSTE_DISTANT, UTILISATEUR, MOT_DE_PASSE, "\"$PWD/.profile\"");
   sLogger.debug("sortie = " + sortie);
} catch (Exception e) {
   sLogger.error(e);
   assertTrue("Test 1.1 Une Exception n'aurait pas dû intervenir", false);
}
Ce code fonctionne bien sur un poste distant, mais pas sur un autre.
djanggawul est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/11/2006, 20h45   #4
Rédacteur/Modérateur
 
Avatar de troumad
 
Homme Bernard SIAUD
Enseignant
Inscription : novembre 2003
Messages : 4 400
Détails du profil
Informations personnelles :
Nom : Homme Bernard SIAUD
Âge : 44
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : novembre 2003
Messages : 4 400
Points : 4 944
Points : 4 944
Si je ne me trompe pas...
Ça ne dépend pas du shell défini par défaut ?
.bashrc si c'est le bash ? NOn ?
__________________
Modérateur Mandriva Linux
Amicalement VOOotre
Troumad Alias Bernard SIAUD à découvrir sur http://troumad.org
Mes tutoriels
troumad est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/11/2006, 11h00   #5
Invité régulier
 
Inscription : novembre 2006
Messages : 32
Détails du profil
Informations forums :
Inscription : novembre 2006
Messages : 32
Points : 9
Points : 9
Par défaut Problème résolu

Je viens de trouver le pourquoi de mon problème.

En fait, le fichier .profile contenait une commande stty qui permet, si j'ai bien compris, de modifier les modes de transmission du terminal.

Je ne sais pas quel est le terminal offert lors d'une connexion SSH mais elle ne supporte pas, à priori, la commande stty. Donc, l'exécution de cette commande par SSH transmettait l'erreur:
Code :
1
2
3
 
Not a terminal
stty: : Not a typewriter
djanggawul est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 23h19.


 
 
 
 
Partenaires

Hébergement Web