sudo apt-get update
sudo apt-get install openssh-server
Tips
If the linux system runs in the docker container, thenneed to execute this step on the host. Visit the port of the Docker host directly (the port is mapped to port 22 of this container).docker run --name lianxi -d -p 7000:22 -p 7001:5050 nginx
will check the IP address in the host, and use the IP address and the 7000 port to access the container
ifconfig
command
If it appearsbash: ipconfig: command not found
may be that the system does not have an ipconfig. At this time
yum install upgrade
yum install net-times
or
Sudo Apt-get update
SUDO APT-get install net-times
and then you can view the IP address
At this step, you can set the password of the root account directly, or you can add a new user
Modify the user password
passwd username
If other users are not set at this time, then the Login is accessible through SSH.
1.
vim /etc/sshd/ssh_config
2. Payed it according to i,
The NO after
PermitRootLogin
is changed toyes
Add users
useradd username
Modify the user password
passwd username
sudo service sshd start
I will appear heresshd: unrecognized service
error, the online solution is invalid, the author simply use it directlysudo service ssh start
No other problems have been found at present, as for the specific reason unknown
[email protected]:/# sudo service ssh start
[ ok ] Starting OpenBSD Secure Shell server: sshd.
service ssh status
[email protected]:/# service ssh status
[ ok ] sshd is running.
SSH service has been started
2022.10.25 Supplement:
Inputps -e |grep ssh
-> Enter -> There is SSHD, indicating that the SSH service has been started
If you do not start, enter the “Service SSH Start” -> Enter -> SSH service will start
First enter the/ETC directory, the/ETC directory stores some configuration files, such as Passwd and other configuration files. If you want to log in with SSH remote login, you need to configure the configuration information in the/etc/ssh/ssh/ssh/sshd_config file and edit it with vim. Enter in the command line modevim /etc/ssh/sshd_config
, after entering, enter the editing status according to “i”, find and modify in its file:PasswordAuthentication yes
, PermitRootLogin yes
two lines can be
After the modification is completed, you need to restart the SSH service
Sudo Service SSH RESTART
# Service SSH Start/Stop/Restart/Status // Start/stop/restart/status
If it is a container, use host IP+corresponding container No. 22 to access the host port
Otherwise, access to port No. 22 through the IP in the step 2.
For example, use XSHELL software