Start ssh-agent upon remote SSH login

Usually when you log in through GDM/lightDM…, etc, it’ll start ssh-agent for you. But what if I’m logging in from a remote machine through SSH?

After trying a few scripts on the Internet that doesn’t work, I decided to do it myself.

I’m going to set this up in tcsh environment, so this probably won’t work in bash.

Open ~/.login , tcsh will execute commands in this file after login, add

eval `ssh-agent -c`

And that’s it, basically it just set some environment variables.

eval will take its argument as an command and execute it, `ssh-agent -c` means the output of ssh-agent -c , not the string ‘ssh-agent -c’ itself.

-c will “Generate C-shell commands on stdout." as the manpage said.

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s