SSH configuration and login command in Linux

Source: Internet
Author: User
Tags ssh port number


First, if not installed, then apt-get install SSH on the command line

After a while, you can actually log on to the SSH service machine.

The command to open the SSH service is: sudo/etc/init.d/sshd restart (generate public-private key pair)

View SSH status command: sudo/etc/init.d/sshd status


If you do not start the sshd daemon, you only need: sudo/usr/sbin/sshd (no need to do each)

At logon time, the command: SSH (other IP)-L (the other machine has the user name)-p (port number)

Where the parameter-l-p are not required. If the current user name has the same name as the user on the other machine that you want to log on to, then the-l parameter is not required, and the port defaults to 22 and is usually not set.

Common format: SSH [-l login_name] [P port] [user@]hostname

More details can be viewed with ssh-h.

Example

Do not specify User:

SSH 192.168.0.11

Specify the User:

Ssh-l Root 192.168.0.11

SSH root@192.168.0.11

If you have modified the SSH login port

Ssh-p 12333 192.168.0.11

Ssh-l Root-p 12333 216.230.230.114

Ssh-p 12333 root@216.230.230.114

In addition, modify the profile/etc/ssh/sshd_config, you can change the SSH login port and prevent root login. Changing the port can prevent the port from being scanned.

Edit configuration file

Vim/etc/ssh/sshd_config

Find #port 22, remove the annotation, and modify it into a five-bit port:

Port 12333

Find #permitrootlogin Yes, remove the comment, and modify it to:

Permitrootlogin No

Restart the SSHD service:

Service sshd Restart

Aliases can be used by users to customize their commands. Edit Vim ~/.BASHRC

Alias ll = ' Ls-l '

SOURCE ~/.BASHRC command takes effect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.