0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Linux sshpass 備忘録

Last updated at Posted at 2022-12-06

sshpass インストール

# yum update
# dnf --enablerepo=epel -y install sshpass

使用テスト

ssh

【通常】
sshpass -p 'MyPassword' ssh -o StrictHostKeyChecking=no root@192.168.xx.xx
→-o StrictHostKeyChecking=no: ログイン聞かれない
→初回ログイン時戻り値有り
Warning: Permanently added '192.168.xx.xx' (ECDSA) to the list of known hosts.

scp

【通常】
sshpass -p 'MyPassword' scp -o StrictHostKeyChecking=no sample.txt root@192.168.xx.xx:/home/user/MyDocument
戻り値なし

【ローカルファイルが存在しない】
sshpass -p 'MyPassword' scp -o StrictHostKeyChecking=no sample2.txt root@192.168.xx.xx:/home/user/MyDocument
error
→sample2.txt: No such file or directory

【ホスト側に到達不能】
sshpass -p 'MyPassword' scp -o StrictHostKeyChecking=no sample2.txt root@192.168.xx.99:/home/user2/MyDocument
error
→ssh: Could not resolve hostname 192.168.xx.99: Name or service not known lost connection

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?