Linux ssh服务器配置代码实例
程序员文章站
2022-04-12 18:37:47
使用如下终端命令可以在 linux 主机中安装 ssh服务器sudo apt-get install openssh-serverlin@lin-machine:~$ sudo apt-get ins...
使用如下终端命令可以在 linux 主机中安装 ssh服务器sudo apt-get install openssh-server
lin@lin-machine:~$ sudo apt-get install openssh-server reading package lists... done building dependency tree reading state information... done the following extra packages will be installed: libck-connector0 ncurses-term openssh-client openssh-sftp-server ssh-import-id suggested packages: libpam-ssh keychain monkeysphere rssh molly-guard the following new packages will be installed: libck-connector0 ncurses-term openssh-server openssh-sftp-server ssh-import-id the following packages will be upgraded: openssh-client 1 upgraded, 5 newly installed, 0 to remove and 438 not upgraded. need to get 1,180 kb of archives. after this operation, 3,429 kb of additional disk space will be used. do you want to continue? [y/n] y get:1 http://cn.archive.ubuntu.com/ubuntu/ trusty/main libck-connector0 amd64 0.4.5-3.1ubuntu2 [10.5 kb] get:2 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main openssh-client amd64 1:6.6p1-2ubuntu2.11 [564 kb] get:3 http://cn.archive.ubuntu.com/ubuntu/ trusty/main ncurses-term all 5.9+20140118-1ubuntu1 [243 kb] get:4 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main openssh-sftp-server amd64 1:6.6p1-2ubuntu2.11 [34.1 kb] get:5 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main openssh-server amd64 1:6.6p1-2ubuntu2.11 [318 kb] get:6 http://cn.archive.ubuntu.com/ubuntu/ trusty/main ssh-import-id all 3.21-0ubuntu1 [9,624 b] fetched 1,180 kb in 22s (51.6 kb/s) preconfiguring packages ... selecting previously unselected package libck-connector0:amd64. (reading database ... 168838 files and directories currently installed.) preparing to unpack .../libck-connector0_0.4.5-3.1ubuntu2_amd64.deb ... unpacking libck-connector0:amd64 (0.4.5-3.1ubuntu2) ... preparing to unpack .../openssh-client_1%3a6.6p1-2ubuntu2.11_amd64.deb ... unpacking openssh-client (1:6.6p1-2ubuntu2.11) over (1:6.6p1-2ubuntu2.7) ... selecting previously unselected package ncurses-term. preparing to unpack .../ncurses-term_5.9+20140118-1ubuntu1_all.deb ... unpacking ncurses-term (5.9+20140118-1ubuntu1) ... selecting previously unselected package openssh-sftp-server. preparing to unpack .../openssh-sftp-server_1%3a6.6p1-2ubuntu2.11_amd64.deb ... unpacking openssh-sftp-server (1:6.6p1-2ubuntu2.11) ... selecting previously unselected package openssh-server. preparing to unpack .../openssh-server_1%3a6.6p1-2ubuntu2.11_amd64.deb ... unpacking openssh-server (1:6.6p1-2ubuntu2.11) ... selecting previously unselected package ssh-import-id. preparing to unpack .../ssh-import-id_3.21-0ubuntu1_all.deb ... unpacking ssh-import-id (3.21-0ubuntu1) ... processing triggers for man-db (2.6.7.1-1ubuntu1) ... processing triggers for ureadahead (0.100.0-16) ... ureadahead will be reprofiled on next reboot processing triggers for ufw (0.34~rc-0ubuntu2) ... setting up libck-connector0:amd64 (0.4.5-3.1ubuntu2) ... setting up openssh-client (1:6.6p1-2ubuntu2.11) ... setting up ncurses-term (5.9+20140118-1ubuntu1) ... setting up openssh-sftp-server (1:6.6p1-2ubuntu2.11) ... setting up openssh-server (1:6.6p1-2ubuntu2.11) ... creating ssh2 rsa key; this may take some time ... creating ssh2 dsa key; this may take some time ... creating ssh2 ecdsa key; this may take some time ... creating ssh2 ed25519 key; this may take some time ... ssh start/running, process 17527 setting up ssh-import-id (3.21-0ubuntu1) ... processing triggers for libc-bin (2.19-0ubuntu6.9) ... processing triggers for ureadahead (0.100.0-16) ... processing triggers for ufw (0.34~rc-0ubuntu2) ...
查看当前的虚拟机的ip地址
lin@lin-machine:~$ ifconfig eth0 link encap:ethernet hwaddr 00:0c:29:f1:a1:37 inet addr:192.168.147.136 bcast:192.168.147.255 mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fef1:a137/64 scope:link up broadcast running multicast mtu:1500 metric:1 rx packets:3950 errors:0 dropped:0 overruns:0 frame:0 tx packets:514 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 rx bytes:1453734 (1.4 mb) tx bytes:63371 (63.3 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:180 errors:0 dropped:0 overruns:0 frame:0 tx packets:180 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 rx bytes:13377 (13.3 kb) tx bytes:13377 (13.3 kb)
在pc上查看ip地址
microsoft windows [版本 6.1.7601] 版权所有 (c) 2009 microsoft corporation。保留所有权利。 e:\users\libra>ipconfig windows ip 配置 ... 以太网适配器 vmware network adapter vmnet8: 连接特定的 dns 后缀 . . . . . . . : 本地链接 ipv6 地址. . . . . . . . : fe80::9074:b9f5:ddaf:9082%25 ipv4 地址 . . . . . . . . . . . . : 192.168.147.1 子网掩码 . . . . . . . . . . . . : 255.255.255.0 默认网关. . . . . . . . . . . . . : ... e:\users\libra>
【备注】pc和linux虚拟机在同个网段的
测试他们是否可以ping
lin@lin-machine:~$ ping 192.168.147.1 ping 192.168.147.1 (192.168.147.1) 56(84) bytes of data. 64 bytes from 192.168.147.1: icmp_seq=1 ttl=64 time=0.586 ms 64 bytes from 192.168.147.1: icmp_seq=2 ttl=64 time=0.442 ms 64 bytes from 192.168.147.1: icmp_seq=3 ttl=64 time=0.435 ms ^c --- 192.168.147.1 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 1999ms rtt min/avg/max/mdev = 0.435/0.487/0.586/0.074 ms
【可能存在一些异常的原因】注意: windows 7 默认打开了系统防火墙,是禁ping的,如果在linux下ping windows
7,需要先关闭windows 7 的防火墙。
没有问题后我们在securecrt上开始测试
【备注】根据自己的情况来写ip和主机名
来测试一下
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。