さくらのレンタルサーバにsshでログインする

telnetはそろそろやめようかと。

環境

ssh2用の公開鍵と秘密鍵を生成する

$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/xxx/.ssh/id_dsa): [Enter]
Created directory '/home/xxx/.ssh'.
Enter passphrase (empty for no passphrase): xxx [Enter]
Enter same passphrase again: xxx [Enter]
Your identification has been saved in /home/xxx/.ssh/id_dsa.
Your public key has been saved in /home/xxx/.ssh/id_dsa.pub.
The key fingerprint is:
xxx
    

公開鍵をサーバにアップロードする

$ ftp hostname
Connected to hostname (ip address).
220 hostname FTP server (version) ready.
Name (hostname): username
331 Password required for username.
Password:
230 User username logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd .ssh
250 CWD command successful.
ftp> lcd .ssh
Local directory now /home/xxx/.ssh
ftp> put id_dsa.pub
local: id_dsa.pub remote: id_dsa.pub
227 Entering Passive Mode (ip address)
150 Opening BINARY mode data connection for 'id_dsa.pub'.
226 Transfer complete.
ftp> bye
221 Goodbye. 
    
$ telnet hostname
Trying ip address...
Connected to hostname.
Escape character is '^]'.

FreeBSD/i386 (hostname) (ttyp0)

login: username
Password:
Last login: datetime from ip address
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
        The Regents of the University of California. All rights reserved.

FreeBSD version : datetime

// Sakura internet rental server service

%cd .ssh
%touch authorized_keys
%chmod 600 authorized_keys
%cat id_dsa.pub >> authorized_keys
%rm id_dsa.pub
%logout
Connection closed by foreign host.
    

sshでログインする

$ ssh hostname -l username
The authenticity of host 'hostname (ip address)' can't be established.
DSA key fingerprint is xxx.
Are you sure you want to continue connecting (yes/no)? yes [Enter]
Warning: Permanently added 'hostname,ip address' (DSA) to the list of known hosts.
Enter passphrase for key '/home/xxx/.ssh/id_dsa': xxx [Enter]
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
        The Regents of the University of California. All rights reserved.

FreeBSD version : datetime

// Sakura internet rental server service

%logout
Connection to hostname closed.
    

関連情報

Copyright © 2006, AfternoonTea
All rights reserved.