In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-12-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the docker ubuntu image how to install SSH login-free, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to know about it.
1.docker pull ubuntu:14.04 # get the ubuntu14.04 version from dockerhub
2.docker run-vi ubuntu:14.04 / bin/bash # starts the ubuntu14.04 image to get a running container
3.apt-get update# updates the source information of ubuntu
4.apt-get install openssh-server vim # get openssh-server vim software
5.mkdir-p / var/run/sshd # to start the SSH service normally, you need the directory / var/run/sshd to exist, create it manually and start the service step 6
6./usr/sbin/sshd-D &
7. Check to see if ssh is started
Netstat-tunlp
# # modify the secure login configuration of SSH service and remove the pam login restriction:
8.sed-ri 's/session required pam_loginuid.so/#session required pam_loginuid.so/g' / etc/pam.d/sshd
# create a .ssh directory under the root user directory, and copy the public key information that needs to be logged in (enter directly enter using ssh-keygen-t rsa in the host computer will generate id_rsa and id_rsa.pub by default in / root/.ssh/) copy the contents of id_rsa.pub into the container authorized_keys file
9.mkdir / root/.ssh
10.vim / root/.ssh/authorized_keys
It seems important to add 600 permissions to 11.chmod 600authorized_keys#.
Create the executable run.sh that automatically starts the SSH service and add executable permissions:
12.vim / run.sh
Add content:
#! / bin/bash
/ usr/sbin/sshd-D
13.chmod 777 / run.sh
14. Change the UsePAM yes in container / etc/ssh/sshd_config to no, otherwise it will cause login to succeed and exit immediately.
15.exit exit
16.docker commit Container ID ubuntu-ssh:latest# Save Image
17. Start docker run-d-p 8888pur22 ubuntu:latest / run.sh# to map host port 8888 to container port 22
18.ssh-v 127.0.0.1-p 8888 # need to authorize the / root/.ssh/.id_rsa file in the host to 6000.If the authorization is too large, the permission too open will be prompted.
19. Login successful!
Thank you for reading this article carefully. I hope the article "how to install SSH image without login" shared by the editor will be helpful to everyone. At the same time, I also hope you can support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.