ubuntu开启SSH服务远程登录操作
1、查看openssh-client和openssh-server
ubuntu默认只安装了openssh-client
dpkg -l | grep ssh
ii libssh-4:amd64 0.6.3-4.3 amd64 tiny C SSH library (OpenSSL flavor)
ii openssh-client 1:7.2p2-4ubuntu2.4 amd64 secure shell (SSH) client, for secure access to remote machines
2、安装openssh-server
sudo apt-get install openssh-server
[sudo] password for tcrush:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
ncurses-term openssh-client openssh-sftp-server ssh-import-id
Suggested packages:
ssh-askpass libpam-ssh keychain monkeysphere rssh molly-guard
The following NEW packages will be installed:
ncurses-term openssh-server openssh-sftp-server ssh-import-id
The following packages will be upgraded:
openssh-client
1 upgraded, 4 newly installed, 0 to remove and 417 not upgraded.
Need to get 1,223 kB of archives.
After this operation, 5,149 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
3、查看是否安装成功
dpkg -l | grep ssh
ii libssh-4:amd64 0.6.3-4.3 amd64 tiny C SSH library (OpenSSL flavor)
ii openssh-client 1:7.2p2-4ubuntu2.8 amd64 secure shell (SSH) client, for secure access to remote machines
ii openssh-server 1:7.2p2-4ubuntu2.8 amd64 secure shell (SSH) server, for secure access from remote machines
ii openssh-sftp-server 1:7.2p2-4ubuntu2.8 amd64 secure shell (SSH) sftp server module, for SFTP access from remote machines
ii ssh-import-id 5.5-0ubuntu1 all securely retrieve an SSH public key and install it locally
4、查看是否启动
ps -e | grep ssh
4361 ? 00:00:00 sshd
有sshd说明ssh-server已经启动。
如果没有
sudo /etc/init.d/ssh start或 sudo service ssh start
配置相关:
ssh-server配置文件位于/etc/ssh/sshd_config,在这里可以定义SSH的服务端口,默认端口是22,你可以自己定义成其他端口号,如222。(或把配置文件中的”PermitRootLogin without-password”加一个”#”号,把它注释掉,再增加一句”PermitRootLogin yes”)
然后重启SSH服务:
sudo /etc/init.d/ssh stop
sudo /etc/init.d/ssh start
5、连接
5.1、查看IP地址
ifconfig
ens33 Link encap:Ethernet HWaddr 00:0c:29:15:87:af
inet addr:192.168.170.128 Bcast:192.168.170.255 Mask:255.255.255.0
inet6 addr: fe80::81d3:92bf:1575:5ca4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11486 errors:0 dropped:0 overruns:0 frame:0
TX packets:4557 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:12488965 (12.4 MB) TX bytes:442887 (442.8 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:507 errors:0 dropped:0 overruns:0 frame:0
TX packets:507 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:57234 (57.2 KB) TX bytes:57234 (57.2 KB)
5.2、xshell连接
输入用户名和密码,即可连接