- 網上有很多介紹在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 linuxidc@192.168.1.1
- 摘自:http://www.linuxidc.com/Linux/2010-02/24349.htm
復制代碼然后本機連接,出現了英文,本人自幼在中國生長,不懂得鳥語!所以研究了很久!<ignore_js_op> 后來找到了http://www.unixtutorial.org/2009 ... re-shell-in-ubuntu/,馬上如有天助,跟我遇到的問題都一樣!原來是要輸入yes阿!我習慣性的輸入的都是y,哎!看樣子也的看清楚答問題阿!
- SSH (Secure SHell) is possibly the best way to remotely access a Unix system – it's very secure thanks to automatic encryption of all the traffic, and it's also quite universal because you can do all sorts of things: access remote command line shell, forward graphics session output, establish network tunnels and set up port redirections. Today I'm going to show you how to get started with SSH in Ubuntu.
- Installing SSH server in Ubuntu
- By default, your system will have no SSH service enabled, which means you won't be able to connect to it remotely using SSH protocol (TCP port 22). This means that installing SSH server will be one of the first post-install steps on your system.
- The most common SSH implementation is OpenSSH server, and that's exactly what you want to install.
- Log in with your standard username and password, and run the following command to install openssh-server. You should be using the same username that you specified when installing Ubuntu, as it will be the only account with sudo privileges to run commands as root:
- ubuntu$ sudo apt-get install openssh-server
- [sudo] password for greys:
- Reading package lists... Done
- Building dependency tree
- Reading state information... Done
- Suggested packages:
- rssh molly-guard openssh-blacklist openssh-blacklist-extra
- The following NEW packages will be installed:
- openssh-server
- 0 upgraded, 1 newly installed, 0 to remove and 75 not upgraded.
- Need to get 285kB of archives.
- After this operation, 782kB of additional disk space will be used.
- Get:1 http://ie.archive.ubuntu.com jaunty/main openssh-server 1:5.1p1-5ubuntu1 [
- 285kB]
- Fetched 285kB in 0s (345kB/s)
- Preconfiguring packages ...
- Selecting previously deselected package openssh-server.
- (Reading database ... 101998 files and directories currently installed.)
- Unpacking openssh-server (from .../openssh-server_1%3a5.1p1-5ubuntu1_i386.deb) .
- ..
- Processing triggers for ufw ...
- Processing triggers for man-db ...
- Setting up openssh-server (1:5.1p1-5ubuntu1) ...
- Creating SSH2 RSA key; this may take some time ...
- Creating SSH2 DSA key; this may take some time ...
- * Restarting OpenBSD Secure Shell server sshd [ OK ]
- Verifying your SSH server works
- While you're still on your local desktop session, you can use the ps command to confirm that SSH daemon (sshd) is running:
- ubuntu$ ps -aef | grep sshd
- root 24114 1 0 15:18 ? 00:00:00 /usr/sbin/sshd
- Now that you see it's there, it's time to try connecting:
- ubuntu$ ssh localhost
- Since this is the first time you're trying to connect using SSH, you'll have to answer yes to the following question:
- The authenticity of host 'localhost (::1)' can't be established.
- RSA key fingerprint is 18:4d:96:b3:0d:25:00:c8:a1:a3:84:5c:9f:1c:0d:a5.
- Are you sure you want to continue connecting (yes/no)? yes
- … you'll then be prompted for your own password (remember, the system treats such connection request as if you were connecting remotely, so it can't trust you without confirming your password):
- Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
- greys@localhost's password:
- .. and finally you'll see the usual Ubuntu (Jaunty in this example) banner and prompt:
- Linux ubuntu 2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009 i686
- The programs included with the Ubuntu system are free software;
- the exact distribution terms for each program are described in the
- individual files in /usr/share/doc/*/copyright.
- Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
- applicable law.
- To access official Ubuntu documentation, please visit:
- http://help.ubuntu.com/
- Last login: Fri May 15 15:18:34 2009 from ubuntu
- ubuntu$
- That's it, providing you have your networking configured and you know your IP address or hostname, you can start connecting to your Ubuntu box from remote systems, using the same command. Enjoy!
然后本機是可以連接了!但是外部用putty還是不行!sudo ufw disable 關閉ufw防火牆,發現貌似根本沒開!(也上網查了,自己不裝,系統不會安裝的!)
后來在http://forum.ubuntu.org.cn/viewtopic.php?t=40438,找到了這一行,貌似是系統的安全規則
- iptables是內核模塊刪除不了滴
- 現查看一下你iptables的規則
- sudo iptables -L
- sudo iptables -t nat -L
- 如果都是空的就不是iptables的問題
- 如果有許多規則的話就清空規則並修改默認策略
- sudo iptables -F
- sudo iptables -t nat -F
- sudo iptables -P ACCEPT
- sudo iptables -t nat -P ACCEPT
按着弄了一遍!最后兩條都出現問題了!忘記截圖了!好像是說沒有這個命令,請查閱help什么的!不管!弄完,我去別的電腦上用putty連接,出現證書驗證,yes,進入了!輸入用戶名后,有點慢,修改sudo gedit /etc/ssh/sshd_config
- 找到 GSSAPI options 這一節,將下面兩行注釋掉:
- #GSSAPIAuthentication yes
- #GSSAPIDelegateCredentials no
- 然后重新啟動 ssh 服務即可:
- sudo /etc/init.d/ssh restart
- 摘自:http://blog.istef.info/2008/10/02/setup-ssh-server-on-ubuntu-server/
<ignore_js_op> 我的本來就是注釋掉了阿!呵呵!不修改了!
以上是我安裝ssh,解決的全過程!留着備用!