How to ssh on Debian

How to ssh on Debian

1. installation
>>> apt-get install ssh
PS: This is a convenient way to install both the OpenSSH client and the OpenSSH sever.
    More details: aptitude show ssh
OR:
>>> apt-get install openssh-sever openssh-client

2. Generating public/private key
>>> ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
f5:ce:6e:8c:0c:75:f2:37:6a:17:10:3b:f4:d6:5d:5b root@debX
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|            o   E|
|          .. + .=|
|         .o.= o.o|
|        S. +.+   |
|        .  o. +  |
|         o ooo o |
|          o.= .  |
|           o..   |
+-----------------+
OR:
>>> ssh-keygen -t rsa

3. Configure SSH server/client

3.1 Server:
>>> mkdir $HOME/.ssh
>>> cp id_rsa.pub $HOME/.ssh/authorized_keys
PS: $HOME means the $HOME of the remote user
    i.e. /home/rugby/

3.2 Client:
>>> mkdir ~/.ssh
>>> scp root@remote:/root/.ssh/id_rsa ~/.ssh/

4. Secure issues

Server:
>>> vi /etc/ssh/sshd_config
Port <Number > 1024>
PermitRootLogin no
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
ChallengeResponeAuthentication no
PasswordAuthentication no

Client(auto-login):
>>> vi ~/.ssh/config
Host <Server Name>
HostName <IP Address>
Port <Number > 1024>
User <Remote User>

5. Get Started
>>> ssh user@host
>>> scp user@host:/path/to/file ./
PS: host means server name, not ip address
相關文章
相關標籤/搜索