1# Copyright (c) 2013-2021 by Ron Frederick <ronf@timeheart.net> and others.
2#
3# This program and the accompanying materials are made available under
4# the terms of the Eclipse Public License v2.0 which accompanies this
5# distribution and is available at:
6#
7#     http://www.eclipse.org/legal/epl-2.0/
8#
9# This program may also be made available under the following secondary
10# licenses when the conditions for such availability set forth in the
11# Eclipse Public License v2.0 are satisfied:
12#
13#    GNU General Public License, Version 2.0, or any later versions of
14#    that license
15#
16# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
17#
18# Contributors:
19#     Ron Frederick - initial implementation, API, and documentation
20
21"""SSH constants"""
22
23# Default language for error messages
24DEFAULT_LANG                        = 'en-US'
25
26# Default SSH listening port
27DEFAULT_PORT                        = 22
28
29# SSH message codes
30MSG_DISCONNECT                      = 1
31MSG_IGNORE                          = 2
32MSG_UNIMPLEMENTED                   = 3
33MSG_DEBUG                           = 4
34MSG_SERVICE_REQUEST                 = 5
35MSG_SERVICE_ACCEPT                  = 6
36MSG_EXT_INFO                        = 7
37
38MSG_KEXINIT                         = 20
39MSG_NEWKEYS                         = 21
40
41MSG_KEX_FIRST                       = 30
42MSG_KEX_LAST                        = 49
43
44MSG_USERAUTH_REQUEST                = 50
45MSG_USERAUTH_FAILURE                = 51
46MSG_USERAUTH_SUCCESS                = 52
47MSG_USERAUTH_BANNER                 = 53
48
49MSG_USERAUTH_FIRST                  = 60
50MSG_USERAUTH_LAST                   = 79
51
52MSG_GLOBAL_REQUEST                  = 80
53MSG_REQUEST_SUCCESS                 = 81
54MSG_REQUEST_FAILURE                 = 82
55
56MSG_CHANNEL_OPEN                    = 90
57MSG_CHANNEL_OPEN_CONFIRMATION       = 91
58MSG_CHANNEL_OPEN_FAILURE            = 92
59
60MSG_CHANNEL_WINDOW_ADJUST           = 93
61MSG_CHANNEL_DATA                    = 94
62MSG_CHANNEL_EXTENDED_DATA           = 95
63MSG_CHANNEL_EOF                     = 96
64MSG_CHANNEL_CLOSE                   = 97
65MSG_CHANNEL_REQUEST                 = 98
66MSG_CHANNEL_SUCCESS                 = 99
67MSG_CHANNEL_FAILURE                 = 100
68
69# Messages 90-92 are excluded here as they relate to opening a new channel
70MSG_CHANNEL_FIRST                   = 93
71MSG_CHANNEL_LAST                    = 127
72
73# SSH disconnect reason codes
74DISC_HOST_NOT_ALLOWED_TO_CONNECT    = 1
75DISC_PROTOCOL_ERROR                 = 2
76DISC_KEY_EXCHANGE_FAILED            = 3
77DISC_RESERVED                       = 4
78DISC_MAC_ERROR                      = 5
79DISC_COMPRESSION_ERROR              = 6
80DISC_SERVICE_NOT_AVAILABLE          = 7
81DISC_PROTOCOL_VERSION_NOT_SUPPORTED = 8
82DISC_HOST_KEY_NOT_VERIFIABLE        = 9
83DISC_CONNECTION_LOST                = 10
84DISC_BY_APPLICATION                 = 11
85DISC_TOO_MANY_CONNECTIONS           = 12
86DISC_AUTH_CANCELLED_BY_USER         = 13
87DISC_NO_MORE_AUTH_METHODS_AVAILABLE = 14
88DISC_ILLEGAL_USER_NAME              = 15
89
90DISC_HOST_KEY_NOT_VERIFYABLE        = 9   # Error in naming, left here to not
91                                          # break backward compatibility
92
93# SSH channel open failure reason codes
94OPEN_ADMINISTRATIVELY_PROHIBITED    = 1
95OPEN_CONNECT_FAILED                 = 2
96OPEN_UNKNOWN_CHANNEL_TYPE           = 3
97OPEN_RESOURCE_SHORTAGE              = 4
98
99# Internal failure reason codes
100OPEN_REQUEST_X11_FORWARDING_FAILED  = 0xfffffffd
101OPEN_REQUEST_PTY_FAILED             = 0xfffffffe
102OPEN_REQUEST_SESSION_FAILED         = 0xffffffff
103
104# SSH file transfer packet types
105FXP_INIT                            = 1
106FXP_VERSION                         = 2
107FXP_OPEN                            = 3
108FXP_CLOSE                           = 4
109FXP_READ                            = 5
110FXP_WRITE                           = 6
111FXP_LSTAT                           = 7
112FXP_FSTAT                           = 8
113FXP_SETSTAT                         = 9
114FXP_FSETSTAT                        = 10
115FXP_OPENDIR                         = 11
116FXP_READDIR                         = 12
117FXP_REMOVE                          = 13
118FXP_MKDIR                           = 14
119FXP_RMDIR                           = 15
120FXP_REALPATH                        = 16
121FXP_STAT                            = 17
122FXP_RENAME                          = 18
123FXP_READLINK                        = 19
124FXP_SYMLINK                         = 20
125FXP_STATUS                          = 101
126FXP_HANDLE                          = 102
127FXP_DATA                            = 103
128FXP_NAME                            = 104
129FXP_ATTRS                           = 105
130FXP_EXTENDED                        = 200
131FXP_EXTENDED_REPLY                  = 201
132
133# SSH file transfer open flags
134FXF_READ                            = 0x00000001
135FXF_WRITE                           = 0x00000002
136FXF_APPEND                          = 0x00000004
137FXF_CREAT                           = 0x00000008
138FXF_TRUNC                           = 0x00000010
139FXF_EXCL                            = 0x00000020
140
141# SSH file transfer attribute flags
142FILEXFER_ATTR_SIZE                  = 0x00000001
143FILEXFER_ATTR_UIDGID                = 0x00000002
144FILEXFER_ATTR_PERMISSIONS           = 0x00000004
145FILEXFER_ATTR_ACMODTIME             = 0x00000008
146FILEXFER_ATTR_EXTENDED              = 0x80000000
147FILEXFER_ATTR_UNDEFINED             = 0x7ffffff0
148
149# OpenSSH statvfs attribute flags
150FXE_STATVFS_ST_RDONLY               = 0x1
151FXE_STATVFS_ST_NOSUID               = 0x2
152
153# SSH file transfer error codes
154FX_OK                               = 0
155FX_EOF                              = 1
156FX_NO_SUCH_FILE                     = 2
157FX_PERMISSION_DENIED                = 3
158FX_FAILURE                          = 4
159FX_BAD_MESSAGE                      = 5
160FX_NO_CONNECTION                    = 6
161FX_CONNECTION_LOST                  = 7
162FX_OP_UNSUPPORTED                   = 8
163
164# SSH channel data type codes
165EXTENDED_DATA_STDERR                = 1
166
167# SSH pty mode opcodes
168PTY_OP_END                          = 0
169PTY_VINTR                           = 1
170PTY_VQUIT                           = 2
171PTY_VERASE                          = 3
172PTY_VKILL                           = 4
173PTY_VEOF                            = 5
174PTY_VEOL                            = 6
175PTY_VEOL2                           = 7
176PTY_VSTART                          = 8
177PTY_VSTOP                           = 9
178PTY_VSUSP                           = 10
179PTY_VDSUSP                          = 11
180PTY_VREPRINT                        = 12
181PTY_WERASE                          = 13
182PTY_VLNEXT                          = 14
183PTY_VFLUSH                          = 15
184PTY_VSWTCH                          = 16
185PTY_VSTATUS                         = 17
186PTY_VDISCARD                        = 18
187PTY_IGNPAR                          = 30
188PTY_PARMRK                          = 31
189PTY_INPCK                           = 32
190PTY_ISTRIP                          = 33
191PTY_INLCR                           = 34
192PTY_IGNCR                           = 35
193PTY_ICRNL                           = 36
194PTY_IUCLC                           = 37
195PTY_IXON                            = 38
196PTY_IXANY                           = 39
197PTY_IXOFF                           = 40
198PTY_IMAXBEL                         = 41
199PTY_IUTF8                           = 42
200PTY_ISIG                            = 50
201PTY_ICANON                          = 51
202PTY_XCASE                           = 52
203PTY_ECHO                            = 53
204PTY_ECHOE                           = 54
205PTY_ECHOK                           = 55
206PTY_ECHONL                          = 56
207PTY_NOFLSH                          = 57
208PTY_TOSTOP                          = 58
209PTY_IEXTEN                          = 59
210PTY_ECHOCTL                         = 60
211PTY_ECHOKE                          = 61
212PTY_PENDIN                          = 62
213PTY_OPOST                           = 70
214PTY_OLCUC                           = 71
215PTY_ONLCR                           = 72
216PTY_OCRNL                           = 73
217PTY_ONOCR                           = 74
218PTY_ONLRET                          = 75
219PTY_CS7                             = 90
220PTY_CS8                             = 91
221PTY_PARENB                          = 92
222PTY_PARODD                          = 93
223PTY_OP_ISPEED                       = 128
224PTY_OP_OSPEED                       = 129
225PTY_OP_RESERVED                     = 160
226