0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

シンレンタルサーバーにPowerShellからssh接続する方法

0
Posted at

TeraTerm使うの面倒

シンレンタルサーバーではssh接続にTeraTermを推奨しているが、ポートが10022であったり、ユーザー名とパスフレーズとキーファイルが入力必要であったりと手順が煩雑である。

そこで.ssh/configを使用してシンレンタルサーバーに手軽に接続できる方法をメモ。
この方法はLinuxやmacだけでなくWindowsでも使用できる。Windows11のPowerShellにて動作確認済。

.ssh/configってなに

Windowsだけ使っていると馴染みがないが、ユーザーのホームディレクトリ(フォルダ)の直下に.sshというフォルダがあり、そこにsshコマンドで使用されるキーファイルが保存されている。(Linux、mac等と同様)

configというファイルを作成すると、sshコマンドを使用したときに参照してくれる。
そこに設定を書き込んでおくと、パスフレーズを入力するだけでOKになって大変手軽。

.ssh/configの設定例

.ssh/config
Host shin
    HostName サーバー(ホスト名)
    User ユーザー名
    IdentityFile キーファイル名(フルパス)
    Port 10022
    TCPKeepAlive yes

Host shinの行は、「shin」はなんでもよいが、ログイン時にコマンドで使用する。
キーファイル名は、.sshに保存しているなら~/.ssh/ファイル名でOK。

ログインの仕方

Host shinと書いていた場合のコマンドが以下。

PS 現在ディレクトリ> ssh shin

パスフレーズを訊かれるので入力しよう。クリップボードの内容をSHIFT+INSで貼り付けることもできる。

参考記事

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?