简体   繁体   English

如何在打开新终端时自动登录ssh服务

[英]How to automatically login to ssh serve on opening new terminal

I have a vncsession running on server. 我在服务器上运行vncsession。 Now, whenever I open a new terminal, I have to ssh to another server. 现在,每当我打开一个新的终端,我都必须ssh到另一台服务器。 Till now I have been able to setup ssh such that it doesn't ask for password for this particular server. 直到现在我已经能够设置ssh,这样它就不会要求这个特定服务器的密码。 But I have not been able to automatically do this in new terminal. 但是我无法在新终端中自动执行此操作。 If I add the ssh command to .tcshrc it goes into recursive loop - ssh into server, execute .tcshrc, ssh to server, so on. 如果我将ssh命令添加到.tcshrc,它将进入递归循环 - ssh到服务器,执行.tcshrc,ssh到服务器,依此类推。

I'm using Linux, cshell, Gnome setup. 我正在使用Linux,cshell,Gnome设置。

You should do a hostname check. 你应该做一个主机名检查。 Or something else you could recognize the difference between the client and the target. 或者其他什么你可以认识到客户端和目标之间的区别。 I don't know cshell scripting but in SH you would want to do something like: 我不知道cshell脚本,但在SH中你会想做类似的事情:

# Shell:
if [ $HOSTNAME == "vncserver" ]; then
    ssh $TARGET_BOX;
fi;

# Cshell:
if ( $HOSTNAME == vncserver )
    ssh $TARGET_BOX;
endif

This would enforce that only the svnserver would ssh to the remote system and the remote system won't ssh to itself. 这将强制只有svnserver将ssh到远程系统,并且远程系统不会自动ssh。

I use ssh-agent and keychain that works like a charm and allows keeping some safety on your servers. 我使用ssh-agent和keychain ,它像魅力一样,可以保证你的服务器安全。 Here is another keychain tutorial (sorry, written only in french). 这是另一个钥匙串教程(抱歉,只用法语写)。 Just putting your keychain commands in your bashrc or profile that runs at tty start. 只需将钥匙串命令放在btyrc或在tty start运行的配置文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM