以下来自网络引用:
1、检查本机是否安装了ssh服务
使用命令:ssh localhost
如果出现以下错误,则很可能是因为还没有安装ssh-server:
ssh: connect to host localhost port 22: Connection refused
表明还没安装ssh服务。
2、安装SSH-server:
sudo apt-get update
sudo apt-get install openssh-server
3、启动SSH-Server
sudo /etc/init.d/ssh start
使用命令:ssh localhost
如果出现以下错误,则很可能是因为还没有安装ssh-server:
ssh: connect to host localhost port 22: Connection refused
表明还没安装ssh服务。
2、安装SSH-server:
sudo apt-get update
sudo apt-get install openssh-server
3、启动SSH-Server
sudo /etc/init.d/ssh start
本机,使用sudo apt-get install openssh-server之后,自动安装openssh-client等各个包;
但使用ssh localhost无法访问,错误信息如下:
ssh: connect to host localhost port 22: Connection refused
通过ps -ef | grep ssh查看,确定sshd进程没有运行,可以使用sudo /etc/init.d/ssh start开启服务,但给出如下提示:
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service ssh start
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start ssh
ssh start/running, process 2937
utility, e.g. service ssh start
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start ssh
ssh start/running, process 2937
说明,新版本的ssh中以后可以直接使用sudoservice ssh start或sudo start ssh直接控制服务的开启了。
如果服务开启有异常或问题,可以重启电脑,再查看下服务状态。
service ssh status
如果出现下列错误,请保证使用sudo执行命令:
name@Linux:~$ stop ssh
stop: Rejected send message, 1 matched rules; type="method_call", sender=":1.59" (uid=1000 pid=3059 comm="stop) interface="com.ubuntu.Upstart0_6.Job" member="Stop" error name="(unset)" requested_reply=0 destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init"))
stop: Rejected send message, 1 matched rules; type="method_call", sender=":1.59" (uid=1000 pid=3059 comm="stop) interface="com.ubuntu.Upstart0_6.Job" member="Stop" error name="(unset)" requested_reply=0 destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init"))
总结如下:
开启ssh:sudo start ssh
关闭ssh:sudo stop ssh
查看ssh运行状态: service ssh status
通过ssh localhost提示输入密码,登录,完成ssh配置,更多安全性配置,自行设置。
windows下使用putty或SecureCRT访问ssh的文档:
http://blog.csdn.net/backtracker/article/details/6642784
http://ubuntu.blog.51cto.com/868790/431677