window7 scp 访问docker容器中镜像

遇到坑不少,做一下记录,备忘!!

准备工作,pull ubuntu   镜像( Ubuntu 18.04.1 )

docker pull ubuntu 

###Docker的Ubuntu镜像安装的容器无ifconfig命令和ping命令

apt-get update
apt install net-tools # ifconfig 
apt install iputils-ping # ping

###查看系统版本

cat /etc/issue

###ssh
#查看ssh

ps -e|grep ssh 

#安装ssh

sudo apt-get install openssh-server

#启动 ssh

service ssh start

#vim

apt-get install vim

###win 添加路由 
#删除
route delete 192.168.100.106
#添加
route add -p 192.168.0.0 mask 255.255.0.0 192.168.100.1
#查看
route print 192.168.100.106

####启动 ubuntu 镜像

docker run -it --rm -p 5022:22 1f89248e3d1f /bin/bash

####一定要修改 docker 镜像ubuntu容器用户密码

 passwd root

### 通常来说,就可以正常登录了,但是我这边仍旧登录不上去, 所以解决方法

etc/ssh/sshd_config 修改该配置文件:

# Authentication:
LoginGraceTime 120
PermitRootLogin without-password
StrictModes yes

将 PermitRootLogin without-password  修改为 PermitRootLogin yes,如下:

# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

配置好后就可以用winscp工具连接了

你的docker容器所分配镜像IP  在加你设置的对外开放的端口

备注:

1.ssh 设置服务自启动

vi /etc/rc.local
/etc/init.d/ssh start

保存退出,最好重启docker ubuntu镜像

2.在docker  镜像命令中 退出

Ctrl + p

Ctrl + q

Ctrl + c

这样就可以在 ubutnu容器不关闭的情况下,退出了

直接退出: exit 

猜你喜欢

转载自www.cnblogs.com/smars1990/p/10297891.html
scp
今日推荐