{"id":332620,"date":"2022-04-29T21:00:17","date_gmt":"2022-04-29T21:00:17","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=332620"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=332620","title":{"rendered":"<span>VPN \u043d\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u043a\u0430\u0445 \u0447.2, \u0438\u043b\u0438 \u0442\u0440\u043e\u0435 \u0432 docker \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u044f \u0442\u0443\u043d\u043d\u0435\u043b\u044f<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a85\/818\/714\/a85818714f039c982ced7f9f5ea40b2f.png\" width=\"780\" height=\"439\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a85\/818\/714\/a85818714f039c982ced7f9f5ea40b2f.png\"\/><figcaption><\/figcaption><\/figure>\n<blockquote>\n<p><em>-\u041d\u0443 \u0447\u0442\u043e, \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442?<\/em><\/p>\n<p><em>-\u0414\u0430, \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b, \u0432\u043e\u0442 \u0441\u043c\u043e\u0442\u0440\u0438\u2026<\/em><\/p>\n<p><em>\u041d\u0430\u043f\u0430\u043b \u0414\u0435\u0434! &#8212; \u0418\u043d\u0436\u0435\u043d\u0435\u0440\u044b-\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0438<\/em><\/p>\n<\/blockquote>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0445\u0430\u0431\u0440!\u00a0<\/p>\n<p>\u041a <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/659031\/\">\u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u0437\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u0432\u043e\u0437\u043d\u0438\u043a \u0440\u044f\u0434 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432, \u0438, \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0440\u0430\u0441\u0441\u043a\u0430\u0437 \u043e \u0432\u043d\u0443\u0442\u0440\u0438\u0432\u0435\u043d\u043d\u043e\u043c \u043a\u0443\u0440\u0441\u0435 \u043e\u0442\u0435\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0432\u043d\u0435\u0441\u0443 \u0440\u044f\u0434 \u0432\u0430\u0436\u043d\u044b\u0445 \u0443\u0442\u043e\u0447\u043d\u0435\u043d\u0438\u0439. \u041a\u0430\u043a \u043c\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 \u0431\u044b\u043b\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0439. \u0421\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c.<\/p>\n<p>\u0412: \u0412\u044b \u0438\u0437\u043e\u0431\u0440\u0435\u043b\u0438 VDI (\u0438\u043b\u0438 {another_technology_name})<\/p>\n<p>\u041e: \u041a\u0430\u043a \u043d\u0438 \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u0432\u044b \u043f\u0440\u0430\u0432\u044b! \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u0441\u044b\u043b\u043a\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u201c\u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430\u201d \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e <strong>\u043d\u0430\u0434\u043e\u0435\u043b\u043e<\/strong> \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u043a\u0443\u0434\u0430 \u0442\u044b\u043a\u0430\u0442\u044c, \u0438.\u0442.\u0434. \u0425\u043e\u0447\u0435\u0442\u0441\u044f, \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u0436\u0435 \u0441\u043f\u043e\u043a\u043e\u0439\u0441\u0442\u0432\u0438\u044f, \u043e\u0434\u043d\u043e\u043a\u043d\u043e\u043f\u043e\u0447\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441.<\/p>\n<p>\u0412: \u041f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Apache Guacamole?<\/p>\n<p>\u041e: \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043d\u0430\u0432\u043e\u0434\u043a\u0443, \u043e \u0442\u0430\u043a\u0438\u0445 \u0432\u0435\u0449\u0430\u0445 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0437\u043d\u0430\u044e, \u043d\u0430\u0434 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u0435 \u0434\u0443\u043c\u0430\u043b. \u0412\u043e\u0437\u044c\u043c\u0443 \u043d\u0430 \u043a\u0430\u0440\u0430\u043d\u0434\u0430\u0448.<\/p>\n<p>\u0412: \u0412\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f <strong>\u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e<\/strong>, \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e <strong>*args,<\/strong> <strong>**kwargs<\/strong><\/p>\n<p>\u041e: \u041f\u043e\u043c\u043d\u0438\u0442\u0435 \u043c\u0435\u043c \u043f\u0440\u043e \u201c\u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0432\u043e\u0440\u043e\u0442\u0430\u201d, \u201c\u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0432\u043e\u0440\u043e\u0442\u0430\u201d, \u201c\u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0432\u043e\u0440\u043e\u0442\u0430 \u0447\u0443\u0442\u044c-\u0447\u0443\u0442\u044c\u201d? \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 &#8212; \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430. \u0411\u043e\u043b\u044c\u0448\u0435 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 &#8212; \u043c\u0435\u043d\u044c\u0448\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u041a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u043c, \u0438\u0437-\u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432\u043e\u043e\u0431\u0449\u0435 \u0440\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u044e\u0434\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0442\u044c \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u043e\u0439. \u0412 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u043c \u0412\u041c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u043c\u0438 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f VPN, \u043d\u043e \u043e\u043d \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f <strong>\u043e\u0434\u0438\u043d<\/strong> \u0440\u0430\u0437. \u0417\u0434\u0435\u0441\u044c \u0436\u0435 \u0446\u0435\u043b\u044c &#8212; \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e (\u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0430\u0434\u043c\u0438\u043d\u0430), \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 &#8212; \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0435 \u0434\u0430\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0438 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0443\u0433\u0440\u043e\u0437\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0430 \u043f\u0430\u0440\u043e\u043b\u044f, \u043b\u0438\u0431\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u043a\u0441\u043f\u043b\u043e\u0439\u0442\u0430. <strong>\u0414\u0430, \u043f\u0443\u0442\u0438 \u043e\u0431\u0445\u043e\u0434\u0430 \u0435\u0441\u0442\u044c.<\/strong> \u041e\u0434\u043d\u0430\u043a\u043e, \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435 forward port \u0432\u043e\u0432\u043d\u0435.<\/p>\n<h3>\u041f\u043b\u0430\u043d \u0432\u0437\u044f\u0442\u0438\u044f \u041f\u0430\u0440\u0438\u0436\u0430<\/h3>\n<p>\u0417\u0430\u043a\u043e\u043d\u0447\u0438\u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0441\u0435\u0430\u043d\u0441 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0441\u0443\u0434\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0441\u0443\u0449\u043d\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b:<\/p>\n<ol>\n<li>\n<p>\u0418\u0437 \u043a\u0430\u043a\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a\u0438\u043c\u0438 \u0431\u0443\u0434\u0443\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0440\u0438\u0441\u043a\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u041e\u0441\u0442\u0430\u0432\u0438\u0432 \u0442\u0440\u0435\u0442\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u201c\u043d\u0430 \u0434\u0435\u0441\u0435\u0440\u0442\u201d, \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. \u0418\u0437 \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441\u043b\u0435\u0434\u0443\u0435\u0442, \u0447\u0442\u043e \u043a\u043b\u0438\u0435\u043d\u0442, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044f \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043a \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0441\u0435\u0430\u043d\u0441\u0443 RDP, \u043f\u0440\u0438\u0447\u0451\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 ssh-\u0442\u0443\u043d\u043d\u0435\u043b\u044c.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f:<\/p>\n<ol>\n<li>\n<p>SSH-\u0442\u0443\u043d\u043d\u0435\u043b\u0438. \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0442\u044c ssh-\u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0432 docker, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0443\u0436\u0435\u043d \u0441\u0435\u0440\u0432\u0438\u0441, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0439, \u043b\u0438\u0431\u043e \u0443\u0431\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u043f\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0443. \u0422\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0412\u041c (\u0441\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043a \u0412\u041c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c). \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u0431\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e \u043a\u0430\u043a\u0438\u043c-\u043b\u0438\u0431\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u043d\u0435 \u0431\u044b\u043b\u0438 \u0448\u0442\u0430\u0442\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u044b \u043f\u0440\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u0435 (IP, \u043b\u043e\u0433\u0438\u043d, \u043f\u0430\u0440\u043e\u043b\u044c), \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f, \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438, \u043e\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0430.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/054\/ae9\/fc3\/054ae9fc3f61ebf50a3ad7ebfa7e79d0.png\" width=\"902\" height=\"742\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/054\/ae9\/fc3\/054ae9fc3f61ebf50a3ad7ebfa7e79d0.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0441\u0445\u0435\u043c\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u0432\u0438\u0434\u0430 <u>https:\/\/forward-me-to-rdp.ru\/xUo64Zz<\/u>.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 websocket \u043a <u>wss:\/\/forward-me-to-rdp.ru<\/u>.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 JRPC \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u0443 <u>xUo64Zz<\/u>.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442 \u0437\u0430\u043d\u044f\u0442 &#8212; \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0435\u0433\u043e \u0437\u0430\u043d\u044f\u0442\u043e\u0441\u0442\u0438, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442 \u0441\u0432\u043e\u0431\u043e\u0434\u0435\u043d:<\/p>\n<ol>\n<li>\n<p>\u0421\u0435\u0440\u0432\u0435\u0440 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 openssh-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u0440\u0442\u0430, \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0430\u0440\u0443 (\u043b\u043e\u0433\u0438\u043d, \u043f\u0430\u0440\u043e\u043b\u044c) \u043e\u0442 ssh, IP-\u0430\u0434\u0440\u0435\u0441 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u0430 \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0441\u0435\u0442\u0438, \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u043d\u0435\u043c\u0443. \u0422\u0430\u043a \u043a\u0430\u043a \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0437\u0430\u0442\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0434 RDP &#8212; \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>\u041a\u043b\u0438\u0435\u043d\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0441 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u0432\u0435\u0431\u0441\u043e\u043a\u0435\u0442, \u0430 \u043d\u0435 REST API, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u043c\u043e\u043c\u0435\u043d\u0442 \u0435\u0433\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 openssh, \u0434\u0430\u0431\u044b \u043e\u043d \u043d\u0435 \u0431\u043e\u043b\u0442\u0430\u043b\u0441\u044f.<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043d\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Python, \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a FastAPI, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430 \u043d\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u043e\u0435 HTTP API (\u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 MVP \u043e\u043d\u043e \u043d\u0430\u043c \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e, \u043d\u043e \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u0434\u043c\u0438\u043d\u043a\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f), \u0435\u0449\u0435 \u043e\u043d \u0443\u043c\u0435\u0435\u0442 \u0432 \u0432\u0435\u0431\u0441\u043e\u043a\u0435\u0442\u044b, \u0447\u0442\u043e \u043d\u0430\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e.<\/p>\n<h3>\u0415\u0445\u0430\u043b docker \u0447\u0435\u0440\u0435\u0437 docker<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0441 openssh-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c. \u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f: alpine, openssh, \u0438 \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430, \u0437\u0430\u0434\u0430\u044e\u0449\u0438\u0439 \u043d\u0443\u0436\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 (\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043d\u0438\u0435 \u0432 sshd_config \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c PermitOpen, \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u044e\u0449\u0438\u043c \u043f\u043e\u0434\u043d\u044f\u0442\u0438\u0435 \u0442\u0443\u043d\u043d\u0435\u043b\u044f \u0434\u043e \u043d\u0443\u0436\u043d\u043e\u0433\u043e host:port).<\/p>\n<pre><code class=\"coffeescript\">FROM alpine:latest LABEL org.opencontainers.image.authors=\"dmitry8912@gmail.com\" COPY sshd_config \/etc\/ssh\/sshd_config COPY run.sh \/root\/run.sh RUN apk add openssh &amp;&amp; chmod +x \/root\/run.sh ENTRYPOINT [\"\/root\/run.sh\"]<\/code><\/pre>\n<p>\u0412 \u0441\u0430\u043c\u043e\u043c Dockerfile \u043d\u0438\u0447\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0432\u043d\u0443\u0442\u0440\u044c sshd_config \u0438 \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430.<\/p>\n<pre><code>PermitRootLogin no MaxSessions 1 AuthorizedKeysFile.ssh\/authorized_keys PasswordAuthentication yes PermitEmptyPasswords no AllowTcpForwarding yes GatewayPorts no X11Forwarding no Subsystemsftp\/usr\/lib\/ssh\/sftp-server<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 ssh-\u0434\u0435\u043c\u043e\u043d\u0430 \u043d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 (\u0445\u043e\u0442\u044f \u043b\u0443\u0447\u0448\u0435 \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0435\u0433\u0434\u0430) \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u043c \u043b\u043e\u0433\u0438\u043d \u043e\u0442 \u043b\u0438\u0446\u0430 root (\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <strong><em>PermitRootLogin<\/em><\/strong>), \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u0439 \u0440\u0430\u0432\u043d\u043e\u0435 \u0435\u0434\u0438\u043d\u0438\u0446\u0435 (\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <strong><em>MaxSessions<\/em><\/strong>), \u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c \u0442\u0443\u043d\u043d\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <strong><em>AllowTcpForwarding<\/em><\/strong>). \u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u0438\u0434\u0430:<\/p>\n<pre><code>PermitOpen my-remote-vm:3389<\/code><\/pre>\n<p>\u0413\u0434\u0435 <strong><em>my-remote-mv<\/em><\/strong> \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043d\u0430 IP-\u0430\u0434\u0440\u0435\u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0441\u0435\u0442\u0438.<\/p>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e &#8212; \u044d\u0442\u043e \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430:<\/p>\n<pre><code class=\"bash\">#!\/bin\/sh # \u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u044e\u0447\u0438 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 ssh-keygen -A # \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043f\u0430\u0440\u043e\u043b\u044c \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0438\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f adduser -D $SSH_USER &amp;&amp; echo \"$SSH_USER:$SSH_PASS\" | chpasswd # \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0443, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0443\u044e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0442\u0443\u043d\u043d\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 sshd printf \"\\nPermitOpen $TO_HOST:3389\" >> \/etc\/ssh\/sshd_config # \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c ssh-\u0441\u0435\u0440\u0432\u0435\u0440 \/usr\/sbin\/sshd -D<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>docker run<\/code> \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c ssh-\u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0435\u043c\u0443 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043f\u0430\u0440\u043e\u043b\u044c, \u0438 ip-\u0430\u0434\u0440\u0435\u0441 \u0434\u043b\u044f \u0442\u0443\u043d\u043d\u0435\u043b\u044f.<\/p>\n<pre><code class=\"bash\"># \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u043e\u0431\u0440\u0430\u0437 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e dockerfile docker build -t miniv .  # \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0443 docker run --env SSH_USER=habr45j7 --env SSH_PASSWORD=sByj9FvZgQumQj4T --env TO_HOST=172.22.0.109 -it --rm -p \"3022:22\" minivtest<\/code><\/pre>\n<p>\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0433\u043e\u0442\u043e\u0432\u0430, \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 MVP \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u0414\u043b\u044f pyhton \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 <a href=\"https:\/\/docker-py.readthedocs.io\/en\/stable\/containers.html\">\u043f\u0430\u043a\u0435\u0442 docker-py<\/a>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0437\u044b, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b, \u043f\u043e \u0441\u0443\u0442\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e. \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 docker \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441-\u043e\u0431\u0435\u0440\u0442\u043a\u0443:<\/p>\n<pre><code class=\"python\">import docker   class MiniVContainerManager:     __containers = dict()     __instance = None     __client = None     __image_name = 'miniv-gw'      @staticmethod     def get_instance():         if MiniVContainerManager.__instance is None:             MiniVContainerManager.__instance = MiniVContainerManager()         return MiniVContainerManager.__instance      def __int__(self):         self.__client = docker.DockerClient(base_url='unix:\/\/var\/run\/docker.sock')      def build_image(self):         return self.__client.images.build(path='..\/build', tag=MiniVContainerManager.__image_name)      def get_image(self):         self.__client = docker.DockerClient(base_url='unix:\/\/var\/run\/docker.sock')         return self.__client.images.get(MiniVContainerManager.__image_name)      def run_container(self, client_id: str, external_port: int, ssh_username: str, ssh_password: str,                       tunnel_destination: str):         self.__client = docker.DockerClient(base_url='unix:\/\/var\/run\/docker.sock')         img = self.get_image()         container = self.__client.containers.run(img,                                                  detach=True,                                                  remove=True,                                                  environment={                                                      \"SSH_USER\": ssh_username,                                                      \"SSH_PASS\": ssh_password,                                                      \"TO_HOST\": tunnel_destination                                                  },                                                  ports={'22\/tcp': external_port})         self.__containers[client_id] = container      def stop_container(self, client_id: str):         self.__containers[client_id].stop() <\/code><\/pre>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 websocket-endpoint \u043d\u0430 fastapi:<\/p>\n<pre><code class=\"python\">import json import string from contextlib import closing import random import socket from typing import List from fastapi import FastAPI, WebSocket from starlette.websockets import WebSocketDisconnect from app.container_manager import MiniVContainerManager  app = FastAPI()  class ConnectionManager:     def __init__(self):         self.active_connections: List[WebSocket] = []      async def connect(self, websocket: WebSocket, endpoint_id: str, **kwargs):         await websocket.accept()         self.active_connections.append(websocket)         MiniVContainerManager.get_instance().run_container(endpoint_id,                                                            kwargs['external_port'],                                                            kwargs['username'],                                                            kwargs['password'],                                                            kwargs['to_host'])      def disconnect(self, websocket: WebSocket, endpoint_id: str):         self.active_connections.remove(websocket)         MiniVContainerManager.get_instance().stop_container(endpoint_id)      async def send(self, message: str, websocket: WebSocket):         await websocket.send_text(message)   manager = ConnectionManager()   def get_port():     with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:         s.bind(('', 0))         s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)         return s.getsockname()[1]   @app.websocket(\"\/cjrpc\/{endpoint_id}\") async def websocket_endpoint(websocket: WebSocket, endpoint_id: str):     host = '172.27.2.2'     port = get_port()     username = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(10))     password = ''.join(random.choice(string.ascii_lowercase + string.digits + string.punctuation) for _ in range(23))     await manager.connect(websocket, endpoint_id, external_port=port, username=username, password=password,                           to_host=host)     try:         while True:             result = json.dumps({                 'host': host,                 'ssh_username': username,                 'ssh_password': password,                 'external_port': port             })             await manager.send(result, websocket)             await websocket.receive_text()     except WebSocketDisconnect:         manager.disconnect(websocket, endpoint_id) <\/code><\/pre>\n<p>\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b MVP \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f:<\/p>\n<ol>\n<li>\n<p>\u041a\u043b\u0438\u0435\u043d\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0443, \u0432\u0438\u0434\u0430 <u>https:\/\/forward-me-to-rdp.ru\/xUo64Zz<\/u>.<\/p>\n<\/li>\n<li>\n<p>\u041a\u043b\u0438\u0435\u043d\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 <u>ws:\/\/server\/cjrpc\/xUo64Zz<\/u>.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430:<\/p>\n<ol>\n<li>\n<p>\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043f\u0430\u0440\u043e\u043b\u044c.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u043f\u043e\u0440\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u0430 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440.<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0432 \u043e\u0442\u0432\u0435\u0442.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<li>\n<p>\u041a\u043b\u0438\u0435\u043d\u0442, \u043f\u043e\u043b\u0443\u0447\u0430\u044f \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043f\u043e exception`\u0443 <code>WebSocketDisconnect<\/code> \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u0430\u0441\u0441\u043e\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c, \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0443\u043d\u043d\u0435\u043b\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043a \u0442\u043e\u043c\u0443 IP \u0438 \u043f\u043e\u0440\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u043d \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0435 PermitOpen, \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u044d\u0442\u043e \u043f\u043e\u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0435 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438.<\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9d6\/005\/97f\/9d600597fd60e936fc29057174dd729f.png\" width=\"1299\" height=\"900\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9d6\/005\/97f\/9d600597fd60e936fc29057174dd729f.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439, \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0438 \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u0443\u0435\u043c \u0440\u0438\u0441\u043a\u0438 \u0432 \u043f\u043b\u0430\u043d\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p><a href=\"https:\/\/github.com\/dmitry8912\/mini-v\">GitHub \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/a><\/p>\n<p>\u0425\u043e\u0447\u0443 \u043f\u043e\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u0442\u044c \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0443\u0440\u043e\u043a \u043f\u043e \u0442\u0435\u043c\u0435: &#171;\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0441\u0435\u0442\u044c\u044e&#187;, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 16 \u043c\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0434\u0443\u0442 \u043c\u043e\u0438 \u043a\u043e\u043b\u043b\u0435\u0433\u0438 \u0438\u0437 OTUS. \u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0443\u0440\u043e\u043a <a href=\"https:\/\/otus.pw\/hePg\/\">\u043c\u043e\u0436\u043d\u043e \u0442\u0443\u0442<\/a>.  <\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/663482\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/663482\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<blockquote>\n<p><em>-\u041d\u0443 \u0447\u0442\u043e, \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442?<\/em><\/p>\n<p><em>-\u0414\u0430, \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b, \u0432\u043e\u0442 \u0441\u043c\u043e\u0442\u0440\u0438\u2026<\/em><\/p>\n<p><em>\u041d\u0430\u043f\u0430\u043b \u0414\u0435\u0434! &#8212; \u0418\u043d\u0436\u0435\u043d\u0435\u0440\u044b-\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0438<\/em><\/p>\n<\/blockquote>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0445\u0430\u0431\u0440!\u00a0<\/p>\n<p>\u041a <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/659031\/\">\u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u0437\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u0432\u043e\u0437\u043d\u0438\u043a \u0440\u044f\u0434 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432, \u0438, \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0440\u0430\u0441\u0441\u043a\u0430\u0437 \u043e \u0432\u043d\u0443\u0442\u0440\u0438\u0432\u0435\u043d\u043d\u043e\u043c \u043a\u0443\u0440\u0441\u0435 \u043e\u0442\u0435\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0432\u043d\u0435\u0441\u0443 \u0440\u044f\u0434 \u0432\u0430\u0436\u043d\u044b\u0445 \u0443\u0442\u043e\u0447\u043d\u0435\u043d\u0438\u0439. \u041a\u0430\u043a \u043c\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 \u0431\u044b\u043b\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0439. \u0421\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c.<\/p>\n<p>\u0412: \u0412\u044b \u0438\u0437\u043e\u0431\u0440\u0435\u043b\u0438 VDI (\u0438\u043b\u0438 {another_technology_name})<\/p>\n<p>\u041e: \u041a\u0430\u043a \u043d\u0438 \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u0432\u044b \u043f\u0440\u0430\u0432\u044b! \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u0441\u044b\u043b\u043a\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u201c\u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430\u201d \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e <strong>\u043d\u0430\u0434\u043e\u0435\u043b\u043e<\/strong> \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u043a\u0443\u0434\u0430 \u0442\u044b\u043a\u0430\u0442\u044c, \u0438.\u0442.\u0434. \u0425\u043e\u0447\u0435\u0442\u0441\u044f, \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u0436\u0435 \u0441\u043f\u043e\u043a\u043e\u0439\u0441\u0442\u0432\u0438\u044f, \u043e\u0434\u043d\u043e\u043a\u043d\u043e\u043f\u043e\u0447\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441.<\/p>\n<p>\u0412: \u041f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Apache Guacamole?<\/p>\n<p>\u041e: \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043d\u0430\u0432\u043e\u0434\u043a\u0443, \u043e \u0442\u0430\u043a\u0438\u0445 \u0432\u0435\u0449\u0430\u0445 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0437\u043d\u0430\u044e, \u043d\u0430\u0434 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u0435 \u0434\u0443\u043c\u0430\u043b. \u0412\u043e\u0437\u044c\u043c\u0443 \u043d\u0430 \u043a\u0430\u0440\u0430\u043d\u0434\u0430\u0448.<\/p>\n<p>\u0412: \u0412\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f <strong>\u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e<\/strong>, \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e <strong>*args,<\/strong> <strong>**kwargs<\/strong><\/p>\n<p>\u041e: \u041f\u043e\u043c\u043d\u0438\u0442\u0435 \u043c\u0435\u043c \u043f\u0440\u043e \u201c\u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0432\u043e\u0440\u043e\u0442\u0430\u201d, \u201c\u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0432\u043e\u0440\u043e\u0442\u0430\u201d, \u201c\u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0432\u043e\u0440\u043e\u0442\u0430 \u0447\u0443\u0442\u044c-\u0447\u0443\u0442\u044c\u201d? \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 &#8212; \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430. \u0411\u043e\u043b\u044c\u0448\u0435 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 &#8212; \u043c\u0435\u043d\u044c\u0448\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u041a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u043c, \u0438\u0437-\u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432\u043e\u043e\u0431\u0449\u0435 \u0440\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u044e\u0434\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0442\u044c \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u043e\u0439. \u0412 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u043c \u0412\u041c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u043c\u0438 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f VPN, \u043d\u043e \u043e\u043d \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f <strong>\u043e\u0434\u0438\u043d<\/strong> \u0440\u0430\u0437. \u0417\u0434\u0435\u0441\u044c \u0436\u0435 \u0446\u0435\u043b\u044c &#8212; \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e (\u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0430\u0434\u043c\u0438\u043d\u0430), \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 &#8212; \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0435 \u0434\u0430\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0438 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0443\u0433\u0440\u043e\u0437\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0430 \u043f\u0430\u0440\u043e\u043b\u044f, \u043b\u0438\u0431\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u043a\u0441\u043f\u043b\u043e\u0439\u0442\u0430. <strong>\u0414\u0430, \u043f\u0443\u0442\u0438 \u043e\u0431\u0445\u043e\u0434\u0430 \u0435\u0441\u0442\u044c.<\/strong> \u041e\u0434\u043d\u0430\u043a\u043e, \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435 forward port \u0432\u043e\u0432\u043d\u0435.<\/p>\n<h3>\u041f\u043b\u0430\u043d \u0432\u0437\u044f\u0442\u0438\u044f \u041f\u0430\u0440\u0438\u0436\u0430<\/h3>\n<p>\u0417\u0430\u043a\u043e\u043d\u0447\u0438\u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0441\u0435\u0430\u043d\u0441 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0441\u0443\u0434\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0441\u0443\u0449\u043d\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b:<\/p>\n<ol>\n<li>\n<p>\u0418\u0437 \u043a\u0430\u043a\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a\u0438\u043c\u0438 \u0431\u0443\u0434\u0443\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0440\u0438\u0441\u043a\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u041e\u0441\u0442\u0430\u0432\u0438\u0432 \u0442\u0440\u0435\u0442\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u201c\u043d\u0430 \u0434\u0435\u0441\u0435\u0440\u0442\u201d, \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. \u0418\u0437 \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441\u043b\u0435\u0434\u0443\u0435\u0442, \u0447\u0442\u043e \u043a\u043b\u0438\u0435\u043d\u0442, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044f \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043a \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0441\u0435\u0430\u043d\u0441\u0443 RDP, \u043f\u0440\u0438\u0447\u0451\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 ssh-\u0442\u0443\u043d\u043d\u0435\u043b\u044c.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f:<\/p>\n<ol>\n<li>\n<p>SSH-\u0442\u0443\u043d\u043d\u0435\u043b\u0438. \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0442\u044c ssh-\u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0432 docker, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0443\u0436\u0435\u043d \u0441\u0435\u0440\u0432\u0438\u0441, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0439, \u043b\u0438\u0431\u043e \u0443\u0431\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u043f\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0443. \u0422\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0412\u041c (\u0441\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043a \u0412\u041c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c). \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u0431\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e \u043a\u0430\u043a\u0438\u043c-\u043b\u0438\u0431\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u043d\u0435 \u0431\u044b\u043b\u0438 \u0448\u0442\u0430\u0442\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u044b \u043f\u0440\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u0435 (IP, \u043b\u043e\u0433\u0438\u043d, \u043f\u0430\u0440\u043e\u043b\u044c), \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f, \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438, \u043e\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0430.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0441\u0445\u0435\u043c\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u0432\u0438\u0434\u0430 <u>https:\/\/forward-me-to-rdp.ru\/xUo64Zz<\/u>.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 websocket \u043a <u>wss:\/\/forward-me-to-rdp.ru<\/u>.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 JRPC \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u0443 <u>xUo64Zz<\/u>.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442 \u0437\u0430\u043d\u044f\u0442 &#8212; \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0435\u0433\u043e \u0437\u0430\u043d\u044f\u0442\u043e\u0441\u0442\u0438, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442 \u0441\u0432\u043e\u0431\u043e\u0434\u0435\u043d:<\/p>\n<ol>\n<li>\n<p>\u0421\u0435\u0440\u0432\u0435\u0440 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 openssh-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u0440\u0442\u0430, \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0430\u0440\u0443 (\u043b\u043e\u0433\u0438\u043d, \u043f\u0430\u0440\u043e\u043b\u044c) \u043e\u0442 ssh, IP-\u0430\u0434\u0440\u0435\u0441 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u0430 \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0441\u0435\u0442\u0438, \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u043d\u0435\u043c\u0443. \u0422\u0430\u043a \u043a\u0430\u043a \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0437\u0430\u0442\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0434 RDP &#8212; \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>\u041a\u043b\u0438\u0435\u043d\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0441 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u0432\u0435\u0431\u0441\u043e\u043a\u0435\u0442, \u0430 \u043d\u0435 REST API, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u043c\u043e\u043c\u0435\u043d\u0442 \u0435\u0433\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 openssh, \u0434\u0430\u0431\u044b \u043e\u043d \u043d\u0435 \u0431\u043e\u043b\u0442\u0430\u043b\u0441\u044f.<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043d\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Python, \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a FastAPI, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430 \u043d\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u043e\u0435 HTTP API (\u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 MVP \u043e\u043d\u043e \u043d\u0430\u043c \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e, \u043d\u043e \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u0434\u043c\u0438\u043d\u043a\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f), \u0435\u0449\u0435 \u043e\u043d \u0443\u043c\u0435\u0435\u0442 \u0432 \u0432\u0435\u0431\u0441\u043e\u043a\u0435\u0442\u044b, \u0447\u0442\u043e \u043d\u0430\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e.<\/p>\n<h3>\u0415\u0445\u0430\u043b docker \u0447\u0435\u0440\u0435\u0437 docker<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0441 openssh-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c. \u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f: alpine, openssh, \u0438 \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430, \u0437\u0430\u0434\u0430\u044e\u0449\u0438\u0439 \u043d\u0443\u0436\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 (\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043d\u0438\u0435 \u0432 sshd_config \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c PermitOpen, \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u044e\u0449\u0438\u043c \u043f\u043e\u0434\u043d\u044f\u0442\u0438\u0435 \u0442\u0443\u043d\u043d\u0435\u043b\u044f \u0434\u043e \u043d\u0443\u0436\u043d\u043e\u0433\u043e host:port).<\/p>\n<pre><code class=\"coffeescript\">FROM alpine:latest LABEL org.opencontainers.image.authors=\"dmitry8912@gmail.com\" COPY sshd_config \/etc\/ssh\/sshd_config COPY run.sh \/root\/run.sh RUN apk add openssh &amp;&amp; chmod +x \/root\/run.sh ENTRYPOINT [\"\/root\/run.sh\"]<\/code><\/pre>\n<p>\u0412 \u0441\u0430\u043c\u043e\u043c Dockerfile \u043d\u0438\u0447\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0432\u043d\u0443\u0442\u0440\u044c sshd_config \u0438 \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430.<\/p>\n<pre><code>PermitRootLogin no MaxSessions 1 AuthorizedKeysFile.ssh\/authorized_keys PasswordAuthentication yes PermitEmptyPasswords no AllowTcpForwarding yes GatewayPorts no X11Forwarding no Subsystemsftp\/usr\/lib\/ssh\/sftp-server<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 ssh-\u0434\u0435\u043c\u043e\u043d\u0430 \u043d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 (\u0445\u043e\u0442\u044f \u043b\u0443\u0447\u0448\u0435 \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0435\u0433\u0434\u0430) \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u043c \u043b\u043e\u0433\u0438\u043d \u043e\u0442 \u043b\u0438\u0446\u0430 root (\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <strong><em>PermitRootLogin<\/em><\/strong>), \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u0439 \u0440\u0430\u0432\u043d\u043e\u0435 \u0435\u0434\u0438\u043d\u0438\u0446\u0435 (\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <strong><em>MaxSessions<\/em><\/strong>), \u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c \u0442\u0443\u043d\u043d\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <strong><em>AllowTcpForwarding<\/em><\/strong>). \u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u0438\u0434\u0430:<\/p>\n<pre><code>PermitOpen my-remote-vm:3389<\/code><\/pre>\n<p>\u0413\u0434\u0435 <strong><em>my-remote-mv<\/em><\/strong> \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043d\u0430 IP-\u0430\u0434\u0440\u0435\u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0441\u0435\u0442\u0438.<\/p>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e &#8212; \u044d\u0442\u043e \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430:<\/p>\n<pre><code class=\"bash\">#!\/bin\/sh # \u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u044e\u0447\u0438 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 ssh-keygen -A # \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043f\u0430\u0440\u043e\u043b\u044c \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0438\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f adduser -D $SSH_USER &amp;&amp; echo \"$SSH_USER:$SSH_PASS\" | chpasswd # \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0443, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0443\u044e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0442\u0443\u043d\u043d\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 sshd printf \"\\nPermitOpen $TO_HOST:3389\" >> \/etc\/ssh\/sshd_config # \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c ssh-\u0441\u0435\u0440\u0432\u0435\u0440 \/usr\/sbin\/sshd -D<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>docker run<\/code> \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c ssh-\u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0435\u043c\u0443 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043f\u0430\u0440\u043e\u043b\u044c, \u0438 ip-\u0430\u0434\u0440\u0435\u0441 \u0434\u043b\u044f \u0442\u0443\u043d\u043d\u0435\u043b\u044f.<\/p>\n<pre><code class=\"bash\"># \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u043e\u0431\u0440\u0430\u0437 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e dockerfile docker build -t miniv .  # \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0443 docker run --env SSH_USER=habr45j7 --env SSH_PASSWORD=sByj9FvZgQumQj4T --env TO_HOST=172.22.0.109 -it --rm -p \"3022:22\" minivtest<\/code><\/pre>\n<p>\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0433\u043e\u0442\u043e\u0432\u0430, \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 MVP \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u0414\u043b\u044f pyhton \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 <a href=\"https:\/\/docker-py.readthedocs.io\/en\/stable\/containers.html\">\u043f\u0430\u043a\u0435\u0442 docker-py<\/a>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0437\u044b, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b, \u043f\u043e \u0441\u0443\u0442\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e. \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 docker \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441-\u043e\u0431\u0435\u0440\u0442\u043a\u0443:<\/p>\n<pre><code class=\"python\">import docker   class MiniVContainerManager:     __containers = dict()     __instance = None     __client = None     __image_name = 'miniv-gw'      @staticmethod     def get_instance():         if MiniVContainerManager.__instance is None:             MiniVContainerManager.__instance = MiniVContainerManager()         return MiniVContainerManager.__instance      def __int__(self):         self.__client = docker.DockerClient(base_url='unix:\/\/var\/run\/docker.sock')      def build_image(self):         return self.__client.images.build(path='..\/build', tag=MiniVContainerManager.__image_name)      def get_image(self):         self.__client = docker.DockerClient(base_url='unix:\/\/var\/run\/docker.sock')         return self.__client.images.get(MiniVContainerManager.__image_name)      def run_container(self, client_id: str, external_port: int, ssh_username: str, ssh_password: str,                       tunnel_destination: str):         self.__client = docker.DockerClient(base_url='unix:\/\/var\/run\/docker.sock')         img = self.get_image()         container = self.__client.containers.run(img,                                                  detach=True,                                                  remove=True,                                                  environment={                                                      \"SSH_USER\": ssh_username,                                                      \"SSH_PASS\": ssh_password,                                                      \"TO_HOST\": tunnel_destination                                                  },                                                  ports={'22\/tcp': external_port})         self.__containers[client_id] = container      def stop_container(self, client_id: str):         self.__containers[client_id].stop() <\/code><\/pre>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 websocket-endpoint \u043d\u0430 fastapi:<\/p>\n<pre><code class=\"python\">import json import string from contextlib import closing import random import socket from typing import List from fastapi import FastAPI, WebSocket from starlette.websockets import WebSocketDisconnect from app.container_manager import MiniVContainerManager  app = FastAPI()  class ConnectionManager:     def __init__(self):         self.active_connections: List[WebSocket] = []      async def connect(self, websocket: WebSocket, endpoint_id: str, **kwargs):         await websocket.accept()         self.active_connections.append(websocket)         MiniVContainerManager.get_instance().run_container(endpoint_id,                                                            kwargs['external_port'],                                                            kwargs['username'],                                                            kwargs['password'],                                                            kwargs['to_host'])      def disconnect(self, websocket: WebSocket, endpoint_id: str):         self.active_connections.remove(websocket)         MiniVContainerManager.get_instance().stop_container(endpoint_id)      async def send(self, message: str, websocket: WebSocket):         await websocket.send_text(message)   manager = ConnectionManager()   def get_port():     with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:         s.bind(('', 0))         s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)         return s.getsockname()[1]   @app.websocket(\"\/cjrpc\/{endpoint_id}\") async def websocket_endpoint(websocket: WebSocket, endpoint_id: str):     host = '172.27.2.2'     port = get_port()     username = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(10))     password = ''.join(random.choice(string.ascii_lowercase + string.digits + string.punctuation) for _ in range(23))     await<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-332620","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/332620","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=332620"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/332620\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=332620"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=332620"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=332620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}