ubuntu 开启远程连接 ssh

来源:互联网 发布:商家给淘宝开具什么 编辑:程序博客网 时间:2024/05/22 05:20

Source :http://ubuntuhandbook.org/index.php/2014/09/enable-ssh-in-ubuntu-14-10-server-desktop/

Secure Shell (SSH) is a protocol for securely accessing remote machine, it allows you to run command line and graphical programs, transfer files, and even create secure virtual private networks over the Internet.

Ubuntu does not provide the ssh service out-of-the-box. But you can easily enable it by installing the OpenSSH server package.

To enable SSH:

Search for and install the openssh-server package from Ubuntu Software Center. Or run command below in console if you’re on Ubuntu Server without GUI:

sudo apt-get install openssh-server

Once installed, the SSH service should be started automatically. If necessary, you can start (or stop, restart) the service manually via command:

sudo service ssh start

To edit settings:

To change the port, root login permission, you may edit the/etc/ssh/sshd_config file via:

sudo nano /etc/ssh/sshd_config

After you changed the configurations, press Ctrl+X followed by typing y and hitting enter to save the file.

Finally restart the SSH service to apply the changes:

sudo service ssh restart

Usage and Tips:

1. Normally, we can access remote machine through SSH via command:

ssh username@remote-ip

For the port that is not the default 22:

ssh username@remote-ip -p NUMBER

2. For desktop Ubuntu, root user need to be enabled first so that remote machines can SSH to it via root:

Run command below to set a password for root:

sudo passwd root

Then execute command to unlock the root account:

sudo passwd -u root

Edit the config file /etc/ssh/sshd_config, change the line

PermitRootLogin without-password

into:

PermitRootLogin yes

When done, restart the SSH service.


0 0
原创粉丝点击