Install openssh
Update first
1 | sudo apt-get update -y |
Install openssh-server
1 | sudo apt install openssh-server -y |
Usage
Check IP by
1 | ifconfig |
If you got this:
Install ifconfig
by
1 | sudo apt install net-tools -y |
Or use the command to get your IP address
1 | ip addr |
And connect via
1 | ssh <username>@<hostname> |
Or
1 | ssh <username>@<hostname> -p <port> |
To using default 22 port to connect
Enable ssh service start on boot:
1 | sudo systemctl enable ssh |
Let firewall allow ssh service
1 | sudo ufw allow ssh |
Allow root login
1 | sudo vim /etc/ssh/sshd_config |
ssh keyless login
Create ssh rsa key on the computer you want to connect to host
1 | [neil@yimincai.net ~]$ ssh-keygen -t rsa |
Create .ssh Directory on host server
1 | [neil@yimincai.net ~]$ ssh alyssa@192.168.50.6 mkdir -p .ssh |
Copy public key from local to host server
1 | cat ~/.ssh/id_rsa.pub | ssh alyssa@192.168.50.6 'cat >> .ssh/authorized_keys' |
On host server restart ssh service
1 | service ssh restatus |
On host server check ssh service status
1 | service ssh status |