2012-03-12 19:37:26 +0000 2012-03-12 19:37:26 +0000
54
54

キーファイルをパラメータとして使用して scp'ing、可能であればどのようにそれを行うことができますか?

scp -i ~/.ssh/id_rsa.pub events*$date*_QA.log $remote_user@$remote_server:$remote_location

前述のスクリプトが間違っているのでしょうか?私のやり方が間違っているのでしょうか?

.ssh ディレクトリに行ってみたら、known_hosts ファイルの中にリモートサーバが入っていました。

scp events*$date*_QA.log $remote_user@$remote_server:$remote_location

回答 (3)

70
70
70
2012-03-12 21:17:14 +0000
-i identity_file
         Selects the file from which the identity (private key) for public
         key authentication is read. This option is directly passed to
         ssh(1).

~/.ssh/id_rsaを使用します。

1
1
1
2019-07-11 15:53:49 +0000

これは別の初心者の助けになるかもしれません。

[これは冗長な循環例だと分かっていますが、説明するには良いでしょう] シナリオ:

  1. ssh from Mac -> Ubuntu
  2. scp files from Mac -> Ubuntu
  3. close ssh and scp files from Ubuntu -> Mac

私は、(ssh-keygen経由で)私のMacにssh鍵を作成し、(ssh-copy-id経由で)Ubuntuを実行しているマシンと共有していただけでした。そのため、Ubuntuを実行しているマシンからMacにログインしている間にファイルをコピーすることはできましたが、その逆はできませんでした。

解決方法。そうすると、Ubuntuマシン上で以下のコマンドを実行することができました。

Mac IP: 192.168.1.40
Ubuntu IP: 192.168.1.38

Mac上で

ssh-keygen
ssh-copy-id ubuntu@192.168.1.38

ssh ubuntu@192.168.1.38

# Now on Ubuntu
ssh-keygen
ssh-copy-id MAC@192.168.1.40

**以下のコマンドを実行すると、パスワードを聞かずにファイルをMAC

sudo scp -i /home/ubuntu/.ssh/id_rsa MAC@192.168.1.40:~/Documents/Fluff/Version-Control/tools/pull.sh .
``` にコピーすることができます。
0
0
0
2016-05-24 21:39:24 +0000

以下の手順でテストして修正しました https://askubuntu.com/questions/46930/how-can-i-set-up-password-less-ssh-login

私のボックス (CentOS/CentOS) でテストしたところ、ここの手順は完璧に動作しました。問題は、あなたの ssh 鍵がユーザ名と結びついていないことだと思います。

例。cat authorizedkeys # on Box I’m sshing/scpin’ to ssh-. RSA BLAHBLAHBLAH/zAcS4kD9pyPAjD3/gd5D1rcQa6IztCMR9yMXiGFnxviWsT8/oYevZw25k4yREuA8ibLKC9peH1X4LK1E+n7gq4TETexWkZbQ2XGLOX44eglra3MB4FShPg0cZXGcJWltPQ/y0Ay2A/KmaC14YrDfqwm7+ibTiUp4hOO8I6eIPmwwGn/2hs0SewJXisGqUx2v。myuser@machine.local #usernameは鍵に紐付けられており、認可されたホストです。

関連する質問

6
10
19
12
6