网上有很多介绍在Ubuntu下开启SSH服务的文章,但大多数介绍的方法测试后都不太理想,均不能实现远程登录到Ubuntu上,最后分析原因是都没有真正开启ssh-server服务。最终成功的方法如下: sudo apt-get install openssh-server Ubuntu缺省安装了openssh-client,所以在这里就不安装了,如果你的系统没有安装的话,再用apt-get安装上即可。 然后确认sshserver是否启动了: ps -e |grep ssh 如果只有ssh-agent那ssh-server还没有启动,需要/etc/init.d/ssh start,如果看到sshd那说明ssh-server已经启动了。 ssh-server配置文件位于/ etc/ssh/sshd_config,在这里可以定义SSH的服务端口,默认端口是22,你可以自己定义成其他端口号,如222。然后重启SSH服务: sudo /etc/init.d/ssh resar ssh连接:ssh xjtu129@202.117.15.165
Browsing the archives for the ssh tag
Q:有些时候我们需要修改服务器的ip,但服务器又不在本地,只能ssh连接,这个时候怎么办哪? A:/etc/rc.d/netif restart && /etc/rc.d/routing restart 以下是freebsd下的相关命令: #关闭网卡 ifconfig network-interface down #启动网卡 ifconfig network-interface up #查看尚未启动的网卡 ifconfig -d #查看已启动网卡 #重启路由 /etc/rc.d/routing restart
法1. #ee /etc/hosts.allow 在ALL : ALL : allow的前面加上 sshd : your IP : allow sshd : ALL : deny 就OK了。 法2. 修改/etc/ssh/sshd_config 加入 Allowusers admin@172.16.2.188 意思为 只允许admin从172.16.2.188登陆 法3. 防火墙
编辑/etc/ssh/sshd_config 保证设置以下参数: PermitRootLogin yes PasswordAuthentication yes UseDNS no LoginGraceTime 0
sshd的配置文件一般位于/etc/ssh/sshd_config。
终端下:#ee /etc/ssh/sshd_config
———————————————
#Protocol 2,1
修改为:
Protocol 2
#ListenAddress 0.0.0.0
修改为:
ListenAddress 0.0.0.0
#PermitRootLogin yes
修改为
PermitRootLogin yes
(Linux上默认允许root用户登录,此处可不修改。)
首先vi编辑/etc/inetd.conf,去掉ssh前的#,保存退出
编辑/etc/rc.conf
最后加入:sshd_enable=”yes”即可
激活sshd服务:
techo#/etc/rc.d/sshd start
用下面命令检查服务是否启动,在22端口应该有监听。
#netstat -an ## check port number 22
最后
vi /etc/ssh/sshd_config