2017 09,22 15:09 |
|
ちょっとハマったので、記載
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/hoge/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/hoge/.ssh/id_rsa.
Your public key has been saved in /home/hoge/.ssh/id_rsa.pub.
The key fingerprint is:
1c:c8:cf:03:78:18:d6:31:e4:13:a0:83:d9:80:5b:d8 hoge@hogehoge.server
The key's randomart image is:
+--[ RSA 2048]----+
|oo ++=. |
|o=Eo *.+ |
|oo+ o B . |
|. . . * . |
| S |
| . |
| |
| |
| |
+-----------------+
$
$ cat id_rsa.pub >authorized_keys
$ ll
合計 16
-rw-rw-r-- 1 hoge hoge 413 9月 22 11:55 2017 authorized_keys
drwxrwxr-x 2 hoge hoge 4096 9月 22 11:54 2017 back
-rw------- 1 hoge hoge 1675 9月 22 11:55 2017 id_rsa
-rw-r--r-- 1 hoge hoge 413 9月 22 11:55 2017 id_rsa.pub
$
$ chmod 0600 authorized_keys
$
$
$ sftp -oIdentityFile=/home/hoge/.ssh/id_rsa hoge@hogehoge.server
Connecting to hogehoge.server...
The authenticity of host 'hogehoge.server (hogehoge.server)' can't be established.
RSA key fingerprint is 57:e4:19:5f:e3:c0:a9:81:54:9d:9a:bc:8d:68:a4:b0.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'hogehoge.server' (RSA) to the list of known hosts.
hoge@hogehoge.server's password:
Permission denied, please try again.
hoge@hogehoge.server's password:
Permission denied, please try again.
hoge@hogehoge.server's password:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
Couldn't read packet: Connection reset by peer
$
$
$ ll
合計 20
-rw------- 1 hoge hoge 413 9月 22 11:55 2017 authorized_keys
drwxrwxr-x 2 hoge hoge 4096 9月 22 11:54 2017 back
-rw------- 1 hoge hoge 1675 9月 22 11:55 2017 id_rsa
-rw-r--r-- 1 hoge hoge 413 9月 22 11:55 2017 id_rsa.pub
-rw-r--r-- 1 hoge hoge 395 9月 22 11:55 2017 known_hosts
$
$
$ ssh-copy-id hoge@hogehoge.server
hoge@hogehoge.server's password:
Now try logging into the machine, with "ssh 'hoge@hogehoge.server'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
$ ll
合計 20
-rw------- 1 hoge hoge 413 9月 22 11:55 2017 authorized_keys
drwxrwxr-x 2 hoge hoge 4096 9月 22 11:54 2017 back
-rw------- 1 hoge hoge 1675 9月 22 11:55 2017 id_rsa
-rw-r--r-- 1 hoge hoge 413 9月 22 11:55 2017 id_rsa.pub
-rw-r--r-- 1 hoge hoge 395 9月 22 11:55 2017 known_hosts
$
$ ls -ltr
合計 20
drwxrwxr-x 2 hoge hoge 4096 9月 22 11:54 2017 back
-rw-r--r-- 1 hoge hoge 413 9月 22 11:55 2017 id_rsa.pub
-rw------- 1 hoge hoge 1675 9月 22 11:55 2017 id_rsa
-rw------- 1 hoge hoge 413 9月 22 11:55 2017 authorized_keys
-rw-r--r-- 1 hoge hoge 395 9月 22 11:55 2017 known_hosts
$
$
$
$ sftp -oIdentityFile=/home/hoge/.ssh/id_rsa hoge@hogehoge.server
Connecting to hogehoge.server...
sftp> \q
Invalid command.
sftp>
sftp> quit
$
$ 他のサイトでは、id_rsa.pubを接続先のサーバに持っていき、 authorized_keysに、id_rsa.pubの中身を記述とあったけど、これでうまく行かなかった 他の方法でとして、 $ ssh-copy-id hoge@hogehoge.server として、成功 PR |
|
コメント |
コメント投稿 |
|
忍者ブログ [PR] |