0
点赞
收藏
分享

微信扫一扫

【六袆 - Linux】windos环境中的Docker,使用xshell连接docker容器中的ubuntu18.04;ssh登录docker容器ubuntu18.04


windos环境中的Docker,使用xshell连接docker容器中的ubuntu18.04;








就是这么自信💜

【六袆 - Linux】windos环境中的Docker,使用xshell连接docker容器中的ubuntu18.04;ssh登录docker容器ubuntu18.04_docker

Ubuntu18.04 安装ssh

#换源:1.备份;
mv /etc/apt/sources.list /etc/apt/sourses.list.backup

#2.新建
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

#更新源
sudo apt-get update
sudo apt-get



输入service ssh status 查看ssh状态

【六袆 - Linux】windos环境中的Docker,使用xshell连接docker容器中的ubuntu18.04;ssh登录docker容器ubuntu18.04_docker_02



启动ssh服务

【六袆 - Linux】windos环境中的Docker,使用xshell连接docker容器中的ubuntu18.04;ssh登录docker容器ubuntu18.04_docker_03



实现远程登录的配置

#编辑
vim /etc/ssh/sshd_config

#修改配置
1.将PermitRootLogin的值从withoutPassword改为yes - 允许root登陆
2.将UseDNS yes 改为 UseDNS no - 开始我这个没改,xshell一直报错To escape to local shell, press 'Ctrl+Alt+]'

快速定位,输入指令:/PermitRoot 或者 UseDNS

#重启ssh服务
service ssh



保存容器

#container_id 容器id ,response/tag 任意名称

【六袆 - Linux】windos环境中的Docker,使用xshell连接docker容器中的ubuntu18.04;ssh登录docker容器ubuntu18.04_sed_04



重新运行容器

# 将docker的60001端口和container的22端口绑定,这样访问docker的60001等价于访问container的22端口
docker run -it -p 60001:22 xiaolh/ubuntu-v1 /bin/bash



ssh连接container

#最容易出错的,Docker ip地址 如图

【六袆 - Linux】windos环境中的Docker,使用xshell连接docker容器中的ubuntu18.04;ssh登录docker容器ubuntu18.04_sed_05

恭喜你,又完成了一个亿的小目标~

【六袆 - Linux】windos环境中的Docker,使用xshell连接docker容器中的ubuntu18.04;ssh登录docker容器ubuntu18.04_sed_06


举报

相关推荐

0 条评论