1、ubuntu默认并没有安装ssh服务,如果通过ssh链接ubuntu,需要自己手动安装ssh-server。判断是否安装ssh服务,可以通过如下命令进行:
xjj@xjj-desktop:~$ ssh localhost
ssh: connect to host localhost port 22: Connection refused
如上所示,表示没有还没有安装,可以通过apt安装,命令如下:
sudo apt-get install openssh-server
2、设置自动启动:( 好像安装后默认地已经以openssh-daemon在后台运行了。 也可以使用chkconfig来设置自动启动。)
sudo vi ~/.bashrc
添加
/etc/init.d/ssh start
3、修改配置
ssh-server配置文件位于/ etc/ssh/sshd_config,在这里可以定义SSH的服务端口,默认端口是22,你可以自己定义成其他端口号,如222。然后重启SSH服务:
sudo /etc/init.d/ssh restart
4、查看服务是否启动
ps -e | grep ssh
5、启动服务
$sudo/etc/init.d/ssh resart
Rather than invoking initscripts through /etc/init.d, use the service(8)
utility, e.g. service sshresart