Ubuntu ssh service installation and firewall configuration

Source: Internet
Author: User
Tags ssh server

The ssh link to ubuntu has been faulty all the time. I checked it and it turns out to be the cause of the firewall. By the way, I recorded it.

1> install the SSH server and client

Sudo apt-get install openssh-server openssh-client

2> test and install

Ssh localhost Test
3> SSH remote login to Ubuntu

Ssh username@192.168.0.1

Copy files/folders from remote Ubuntu to local (scp)

Scp-r username@192.168.0.1:/home/username/remotefile.txt.

Copy files/folders from local computer to remote Ubuntu machine (scp)

Scp-r localfile.txt username@192.168.0.1:/home/username/

Copy files/folders from a remote Ubuntu machine to a local machine (rsync)

Rsync-v-u-a -- delete -- rsh = ssh -- stats username@192.168.0.1:/home/username/remotefile.txt.

Copy files/folders from local computer to remote Ubuntu machine (rsync)

Rsync-v-u-a -- delete -- rsh = ssh -- stats localfile.txt username@192.168.0.1:/home/username/

Ufw is installed in ubuntu by default.

(From: http://www.jmhdtv.com/post/198.html)


1. Install
Sudo apt-get install ufw

2. Enable
Sudo ufw enable
Sudo ufw default deny

After running the preceding two commands, the firewall is enabled and automatically enabled when the system starts. Disable all external access to the local machine, but the local access to the external is normal.

3. enable/disable
Sudo ufw allow | deny [service]

Open or close a port, for example:
Sudo ufw allow smtp allows all external IP addresses to access the local port 25/tcp (smtp ).
Sudo ufw allow 22/tcp allows all external IP addresses to access the local port 22/tcp (ssh)
Sudo ufw allow 53 allows external access to port 53 (tcp/udp)
Sudo ufw allow from 192.168.1.100 allows this IP address to access all local ports
Sudo ufw allow proto udp 192.168.0.1 port 53 to 192.168.0.2 port 53
Sudo ufw deny smtp prohibit external access to the smtp service
Sudo ufw delete allow smtp delete a rule created above

4. view the Firewall Status
Sudo ufw status

For general users, only the following settings are required:
Sudo apt-get install ufw
Sudo ufw enable
Sudo ufw default deny

The preceding three commands are safe enough. If you need to open some services, use sudo ufw allow.


Enable/disable firewall ('disable' is set by default ')
Sudo ufw enable | disable

Change log status
Sudo ufw logging on | off

Set the Default policy (for example, "mostly open" vs "mostly closed ")

Sudo ufw default allow | deny

Permit or shield the port (you can view the service list in "status ). You can use "Protocol: Port" to specify a service name that exists in/etc/services, or use the meta-data package. The 'allow' parameter adds the entries to/etc/ufw/maps, while the 'deny' parameter is the opposite. The basic syntax is as follows:
Sudo ufw allow | deny [service]

Display the listening status of the firewall and port. For more information, see/var/lib/ufw/maps. The numbers in the brackets are not displayed.
Sudo ufw status


UFW usage example:

Allow port 53
$ Sudo ufw allow 53

Disable port 53
$ Sudo ufw delete allow 53

Allow port 80
$ Sudo ufw allow 80/tcp

Disable port 80
$ Sudo ufw delete allow 80/tcp

Allow smtp Port
$ Sudo ufw allow smtp

Delete the smtp port license
$ Sudo ufw delete allow smtp

Allow a specific IP Address
$ Sudo ufw allow from 192.168.254.254

Delete the preceding rule
$ Sudo ufw delete allow from 192.168.254.254

 
 
From: an unexpected climax

Related Article

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.